<p></p>
<p align="center">
<img src="https://zqlovejyc.gitee.io/zqutils-js/Images/SQL.png" height="80"/>
</p>
<div align="center">
[![star](https://gitee.com/zqlovejyc/SQLBuilder.Core/badge/star.svg)](https://gitee.com/zqlovejyc/SQLBuilder.Core/stargazers) [![fork](https://gitee.com/zqlovejyc/SQLBuilder.Core/badge/fork.svg)](https://gitee.com/zqlovejyc/SQLBuilder.Core/members) [![GitHub stars](https://img.shields.io/github/stars/zqlovejyc/SQLBuilder.Core?logo=github)](https://github.com/zqlovejyc/SQLBuilder.Core/stargazers) [![GitHub forks](https://img.shields.io/github/forks/zqlovejyc/SQLBuilder.Core?logo=github)](https://github.com/zqlovejyc/SQLBuilder.Core/network) [![GitHub license](https://img.shields.io/badge/license-Apache2-yellow)](https://github.com/zqlovejyc/SQLBuilder.Core/blob/master/LICENSE) [![nuget](https://img.shields.io/nuget/v/Zq.SQLBuilder.Core.svg?cacheSeconds=10800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core)
</div>
<div align="left">
.NET Standard 2.1、.NET 5 版本SQLBuilder,Expression表达式转换为SQL语句,支持SqlServer、MySql、Oracle、Sqlite、PostgreSql;基于Dapper实现了不同数据库对应的数据仓储Repository;
</div>
## 🌭 开源地址
- Gitee:[https://gitee.com/zqlovejyc/SQLBuilder.Core](https://gitee.com/zqlovejyc/SQLBuilder.Core)
- GitHub:[https://github.com/zqlovejyc/SQLBuilder.Core](https://github.com/zqlovejyc/SQLBuilder.Core)
- NuGet:[https://www.nuget.org/packages/Zq.SQLBuilder.Core](https://www.nuget.org/packages/Zq.SQLBuilder.Core)
- MyGet:[https://www.myget.org/feed/zq-myget/package/nuget/Zq.SQLBuilder.Core](https://www.myget.org/feed/zq-myget/package/nuget/Zq.SQLBuilder.Core)
## 🥥 框架扩展包
| 包类型 | 名称 | 版本 | 描述 |
| :---------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------- |
| [![nuget](https://shields.io/badge/-Nuget-blue?cacheSeconds=604800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core) | Zq.SQLBuilder.Core | [![nuget](https://img.shields.io/nuget/v/Zq.SQLBuilder.Core.svg?cacheSeconds=10800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core) | SQLBuilder.Core 核心包 |
| [![nuget](https://shields.io/badge/-Nuget-blue?cacheSeconds=604800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core.SkyWalking) | Zq.SQLBuilder.Core.SkyWalking | [![nuget](https://img.shields.io/nuget/v/Zq.SQLBuilder.Core.SkyWalking.svg?cacheSeconds=10800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core.SkyWalking) | SQLBuilder.Core SkyWalking 扩展包 |
| [![nuget](https://shields.io/badge/-Nuget-blue?cacheSeconds=604800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core.ElasticApm) | Zq.SQLBuilder.Core.ElasticApm | [![nuget](https://img.shields.io/nuget/v/Zq.SQLBuilder.Core.ElasticApm.svg?cacheSeconds=10800)](https://www.nuget.org/packages/Zq.SQLBuilder.Core.ElasticApm) | SQLBuilder.Core ElasticApm扩展包 |
## 🚀 快速入门
- #### ➕ 新增
```csharp
//新增
await _repository.InsertAsync(entity);
//批量新增
await _repository.InsertAsync(entities);
//新增
await SqlBuilder
.Insert<MsdBoxEntity>(() =>
entity)
.ExecuteAsync(
_repository);
//批量新增
await SqlBuilder
.Insert<MsdBoxEntity>(() =>
new[]
{
new UserInfo { Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
})
.ExecuteAsync(
_repository);
```
- #### 🗑 删除
```csharp
//删除
await _repository.DeleteAsync(entity);
//批量删除
await _repository.DeleteAsync(entitties);
//条件删除
await _repository.DeleteAsync<MsdBoxEntity>(x => x.Id == "1");
//删除
await SqlBuilder
.Delete<MsdBoxEntity>()
.Where(x =>
x.Id == "1")
.ExecuteAsync(
_repository);
//主键删除
await SqlBuilder
.Delete<MsdBoxEntity>()
.WithKey("1")
.ExecuteAsync(
_repository);
```
- #### ✏ 更新
```csharp
//更新
await _repository.UpdateAsync(entity);
//批量更新
await _repository.UpdateAsync(entities);
//条件更新
await _repository.UpdateAsync<MsdBoxEntity>(x => x.Id == "1", () => entity);
//更新
await SqlBuilder
.Update<MsdBoxEntity>(() =>
entity,
DatabaseType.MySql,
isEnableFormat:true)
.Where(x =>
x.Id == "1")
.ExecuteAsync(
_repository);
```
- #### 🔍 查询
```csharp
//简单查询
await _repository.FindListAsync<MsdBoxEntity>(x => x.Id == "1");
//连接查询
await SqlBuilder
.Select<UserInfo, UserInfo, Account, Student, Class, City, Country>((u, t, a, s, d, e, f) =>
new { u.Id, UId = t.Id, a.Name, StudentName = s.Name, ClassName = d.Name, e.CityName, CountryName = f.Name })
.Join<UserInfo>((x, t) =>
x.Id == t.Id) //注意此处单表多次Join所以要指明具体表别名,否则都会读取第一个表别名
.Join<Account>((x, y) =>
x.Id == y.UserId)
.LeftJoin<Account, Student>((x, y) =>
x.Id == y.AccountId)
.RightJoin<Student, Class>((x, y) =>
x.Id == y.UserId)
.InnerJoin<Class, City>((x, y) =>
x.CityId == y.Id)
.FullJoin<City, Country>((x, y) =>
x.CountryId == y.Id)
.Where(x =>
x.Id != null)
.ToListAsync(
_repository);
//分页查询
var condition = LinqExtensions
.True<UserInfo, Account>()
.And((x, y) =>
x.Id == y.UserId)
.WhereIf(
!name.IsNullOrEmpty(),
(x, y) => name.EndsWith("∞")
? x.Name.Contains(name.Trim('∞'))
: x.Name == name);
var hasWhere = false;
await SqlBuilder
.Select<UserInfo, Account>(
(u, a) => new { u.Id, UserName = "u.Name" })
.InnerJoin<Account>(
condition)
.WhereIf(
!name.IsNullOrEmpty(),
x => x.Email != null &&
(!name.EndsWith("∞") ? x.Name.Contains(name.TrimEnd('∞', '*')) : x.Name == name),
ref hasWhere)
.WhereIf(
!email.IsNullOrEmpty(),
x => x.Email == email,
ref hasWhere)
.ToPageAsync(
_repository.UseMasterOrSlave(false),
input.OrderField,
input.Ascending,
input.PageSize,
input.PageIndex);
//仓储分页查询
await _repository.FindListAsync(condition, input.OrderField, input.Ascending, input.PageSize, input.PageIndex);
//高级查询
Func<string[], string> @delegate = x => $"ks.{x[0]}{x[1]}{x[2]} WITH(NOLOCK)";
await SqlBuilder
.Select<UserInfo, Account, Student, Class, City, Country>((u, a, s, d, e, f) =>
new { u, a.Name, StudentName = s.Name, ClassName = d.Name, e.CityName, CountryName = f.Name },
tableNameFunc: @delegate)
.Join<Account>((x, y) =>
x.Id == y.UserId,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
.NET Standard 2.1、.NET 5、.NET 6、.NET 7 版本SQLBuilder,Expression表达式转换为SQL语句,支持SqlServer、MySql、Oracle、Sqlite、PostgreSql;基于Dapper实现了不同数据库对应的数据仓储Repository;
资源推荐
资源详情
资源评论
收起资源包目录
Expression表达式转换为SQL语句,支持SqlServer、MySql、Oracle、Sqlite、PostgreSql (109个子文件)
SqlBuilderCore.cs 210KB
BaseRepository.cs 180KB
SelectTest.cs 132KB
IRepository.cs 77KB
LinqExtensions.cs 68KB
MethodCallExpressionResolver.cs 39KB
SqlBuilder.cs 38KB
Program.cs 35KB
SqlWrapper.cs 33KB
IDictionaryExtensions.cs 28KB
ObjectExtensions.cs 24KB
MemberExpressionResolver.cs 23KB
TypeAccessor.cs 19KB
StringExtensions.cs 19KB
IDataReaderExtensions.cs 16KB
BinaryExpressionResolver.cs 16KB
OracleRepository.cs 16KB
IServiceCollectionExtensions.cs 15KB
InsertTest.cs 14KB
SqlBuilderExtensions.cs 13KB
NewExpressionResolver.cs 13KB
BaseExpression.cs 12KB
UnaryExpressionResolver.cs 12KB
ConfigurationManager.cs 11KB
SqlRepository.cs 10KB
TypeExtensions.cs 10KB
ObjectReader.cs 9KB
SqlExpressionProvider.cs 9KB
SqlBuilderDiagnosticListener.cs 9KB
ConstantExpressionResolver.cs 9KB
NpgsqlRepository.cs 9KB
SqliteRepository.cs 8KB
MySqlRepository.cs 8KB
UpdateTest.cs 8KB
ListInitExpressionResolver.cs 7KB
SqlBuilderDiagnosticListener.cs 6KB
MemberInitExpressionResolver.cs 6KB
MemberSet.cs 6KB
SqlBuilderTracingDiagnosticProcessor.cs 6KB
IExpression.cs 5KB
NewArrayExpressionResolver.cs 5KB
WeightRoundRobinLoadBalancer.cs 5KB
OracleDynamicParameters.cs 4KB
SqlBuilderDiagnosticMessage.cs 4KB
ConditionalExpressionReslover.cs 4KB
FormattableStringExtensions.cs 4KB
MemberInfoExtensions.cs 3KB
SqlBuilderDiagnosticExtensions.cs 3KB
RoundRobinLoadBalancer.cs 3KB
DeleteTest.cs 3KB
ObjectAccessor.cs 3KB
DataTypeAttribute.cs 3KB
LambdaExpressionResolver.cs 3KB
SkyWalkingExtensions.cs 3KB
HostedService.cs 3KB
ElasticApmExtension.cs 3KB
DiagnosticsMessage.cs 2KB
CallSiteCache.cs 2KB
RandomLoadBalancer.cs 2KB
KeyAttribute.cs 2KB
DiagnosticStrings.cs 2KB
ColumnInfo.cs 2KB
ColumnAttribute.cs 2KB
SqlBuilderDiagnosticSubscriber.cs 2KB
ParameterExpressionResolver.cs 2KB
TableAttribute.cs 2KB
InvocationExpressionResolver.cs 1KB
DatabaseType.cs 1KB
ILoadBalancer.cs 1KB
OrderType.cs 1KB
User.cs 1007B
MatchType.cs 959B
SqlBuilderObserver.cs 950B
SqlBuilderObserver.cs 949B
OrdinalAttribute.cs 769B
UnitInfoEntity.cs 754B
Teacher.cs 606B
City.cs 585B
Student.cs 466B
User.cs 461B
TestTable.cs 445B
Log.cs 435B
MyStudent.cs 394B
Class.cs 362B
MultiplePrimaryKeyEntity.cs 347B
Account.cs 342B
Class.cs 316B
Student.cs 302B
MyStudent.cs 295B
Account.cs 263B
City.cs 251B
Country.cs 250B
Country.cs 241B
SQLBuilder.Core.csproj 4KB
SQLBuilder.Core.SkyWalking.csproj 3KB
SQLBuilder.Core.Diagnostics.csproj 3KB
SQLBuilder.Core.ElasticApm.csproj 3KB
SQLBuilder.Core.UnitTest.csproj 906B
SQLBuilder.Core.Console.csproj 715B
.gitattributes 2KB
共 109 条
- 1
- 2
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6656
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python tkinter-08-盒子模型.ev4.rar
- Doozy UI Manager 2023
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现无线传感器网络无需测距定位算法matlab源代码 包括apit,dv-hop,amorphous在内的共7个
- 基于python的yolov5实现的旋转目标检测
- 基于matlab实现无线传感器网络 CAB定位仿真程序 这是无线传感器节点定位CAB算法的仿真程序,由matlab完成.rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- springcodespringcodespringcodespringcode
- 基于matlab实现权值的MAXDEV无线传感器网络定位算法研究 MAXDEV 无线传感器 定位 算法.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功