From 1968be0345e1e95d6f01b15aed68a1b621852113 Mon Sep 17 00:00:00 2001
From: 2881099 <2881099@qq.com>
Date: Fri, 8 Nov 2024 15:01:16 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=20FromQuery=20=E5=8F=82?=
=?UTF-8?q?=E6=95=B0=E7=94=B15=E4=B8=AA=E5=8A=A0=E5=88=B016=E4=B8=AA?=
=?UTF-8?q?=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql/FreeSql.xml | 521 ++++++++----------
FreeSql/Interface/Curd/ISelect/ISelect1.cs | 14 +-
.../SelectProvider/Select1Provider.cs | 57 +-
3 files changed, 291 insertions(+), 301 deletions(-)
diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml
index 949513256..325a24319 100644
--- a/FreeSql/FreeSql.xml
+++ b/FreeSql/FreeSql.xml
@@ -1087,93 +1087,6 @@
-
-
- 动态创建实体类型
-
-
-
-
- 配置Class
-
- 类名
- 类标记的特性[Table(Name = "xxx")] [Index(xxxx)]
-
-
-
-
- 获取类型构建器,可作为要构建的Type来引用
-
-
-
-
- 配置属性
-
- 属性名称
- 属性类型
- 属性标记的特性-支持多个
-
-
-
-
- 配置属性
-
- 属性名称
- 属性类型
- 该属性是否重写父类属性
- 属性标记的特性-支持多个
-
-
-
-
- 配置属性
-
- 属性名称
- 属性类型
- 该属性是否重写父类属性
- 属性默认值
- 属性标记的特性-支持多个
-
-
-
-
- 配置父类
-
- 父类类型
-
-
-
-
- Override属性
-
-
-
-
-
- Emit动态创建出Class - Type
-
-
-
-
-
- Emit动态创建出Class - Type,不附带获取TableInfo
-
-
-
-
-
- 首字母小写
-
-
-
-
-
-
- 首字母大写
-
-
-
-
获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 ""
@@ -3376,13 +3289,6 @@
-
-
- 执行SQL语句,返回更新后的记录
- 注意:此方法只有 Postgresql/SqlServer 有效果
-
-
-
指定事务对象
@@ -3727,177 +3633,6 @@
-
-
- 测试数据库是否连接正确,本方法执行如下命令:
- MySql/SqlServer/PostgreSQL/达梦/人大金仓/神通: SELECT 1
- Oracle: SELECT 1 FROM dual
-
- 命令超时设置(秒)
-
- true: 成功, false: 失败
-
-
-
- 查询,若使用读写分离,查询【从库】条件cmdText.StartsWith("SELECT "),否则查询【主库】
-
-
-
-
-
-
-
-
-
- 查询,ExecuteReaderAsync(dr => {}, "select * from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 查询
-
-
-
-
-
-
-
-
- 查询,ExecuteArrayAsync("select * from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 查询
-
-
-
-
-
-
-
-
- 查询,ExecuteDataSetAsync("select * from user where age > @age; select 2", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 查询
-
-
-
-
-
-
-
-
- 查询,ExecuteDataTableAsync("select * from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 在【主库】执行
-
-
-
-
-
-
-
-
- 在【主库】执行,ExecuteNonQueryAsync("delete from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 在【主库】执行
-
-
-
-
-
-
-
-
- 在【主库】执行,ExecuteScalarAsync("select 1 from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
- 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new SqlParameter { ParameterName = "age", Value = 25 })
-
-
-
-
-
-
-
-
-
-
- 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
-
- 执行SQL返回对象集合,Query<User>("select * from user where age > @age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 })
-
-
-
-
-
-
-
-
-
-
-
- 执行SQL返回对象集合,Query<User, Address>("select * from user where age > @age; select * from address", new { age = 25 })
- 提示:parms 参数还可以传 Dictionary<string, object>
-
-
-
-
-
-
-
-
可自定义解析表达式
@@ -4897,12 +4632,6 @@
超时
-
-
- 获取资源
-
-
-
使用完毕后,归还资源
@@ -4978,12 +4707,6 @@
资源对象
-
-
- 从对象池获取对象成功的时候触发,通过该方法统计或初始化对象
-
- 资源对象
-
归还对象给对象池的时候触发
@@ -5897,28 +5620,6 @@
对象池
-
-
- 动态构建Class Type
-
-
-
-
-
- 根据字典,创建 table 对应的实体对象
-
-
-
-
-
-
-
- 根据实体对象,创建 table 对应的字典
-
-
-
-
-
C#: that >= between && that <= and
@@ -6455,3 +6156,225 @@
+
+
+
+
+ 使用 and 拼接两个 lambda 表达式
+
+
+ true 时生效
+
+
+
+
+
+ 使用 or 拼接两个 lambda 表达式
+
+
+
+
+
+ 使用 or 拼接两个 lambda 表达式
+
+
+ true 时生效
+
+
+
+
+
+ 将 lambda 表达式取反
+
+
+ true 时生效
+
+
+
+
+ 使用 and 拼接两个 lambda 表达式
+
+
+
+
+
+ 使用 and 拼接两个 lambda 表达式
+
+
+ true 时生效
+
+
+
+
+
+ 使用 or 拼接两个 lambda 表达式
+
+
+
+
+
+ 使用 or 拼接两个 lambda 表达式
+
+
+ true 时生效
+
+
+
+
+
+ 将 lambda 表达式取反
+
+
+ true 时生效
+
+
+
+
+ 生成类似Mongodb的ObjectId有序、不重复Guid
+
+
+
+
+
+ 插入数据
+
+
+
+
+
+
+ 插入数据,传入实体
+
+
+
+
+
+
+
+ 插入数据,传入实体数组
+
+
+
+
+
+
+
+ 插入数据,传入实体集合
+
+
+
+
+
+
+
+ 插入数据,传入实体集合
+
+
+
+
+
+
+
+ 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下:
+ MySql 5.6+: on duplicate key update
+ PostgreSQL 9.4+: on conflict do update
+ SqlServer 2008+: merge into
+ Oracle 11+: merge into
+ Sqlite: replace into
+ DuckDB: on conflict do update
+ 达梦: merge into
+ 人大金仓:on conflict do update
+ 神通:merge into
+ MsAccess:不支持
+ 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性)
+
+
+
+
+
+
+ 修改数据
+
+
+
+
+
+
+ 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1}
+
+
+ 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合
+
+
+
+
+ 查询数据
+
+
+
+
+
+
+ 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1}
+
+
+ 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合
+
+
+
+
+ 删除数据
+
+
+
+
+
+
+ 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1}
+
+
+ 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合
+
+
+
+
+ 开启事务(不支持异步)
+ v1.5.0 关闭了线程事务超时自动提交的机制
+
+ 事务体 () => {}
+
+
+
+ 开启事务(不支持异步)
+ v1.5.0 关闭了线程事务超时自动提交的机制
+
+
+ 事务体 () => {}
+
+
+
+ 数据库访问对象
+
+
+
+
+ 所有拦截方法都在这里
+
+
+
+
+ CodeFirst 模式开发相关方法
+
+
+
+
+ DbFirst 模式开发相关方法
+
+
+
+
+ 全局过滤设置,可默认附加为 Select/Update/Delete 条件
+
+
+
+
diff --git a/FreeSql/Interface/Curd/ISelect/ISelect1.cs b/FreeSql/Interface/Curd/ISelect/ISelect1.cs
index 60adfdb8d..cf8e38a2f 100644
--- a/FreeSql/Interface/Curd/ISelect/ISelect1.cs
+++ b/FreeSql/Interface/Curd/ISelect/ISelect1.cs
@@ -196,8 +196,20 @@ public interface ISelect : ISelect0, T1>
ISelect FromQuery(ISelect select2, ISelect select3) where T2 : class where T3 : class;
ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4) where T2 : class where T3 : class where T4 : class;
ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5) where T2 : class where T3 : class where T4 : class where T5 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class;
+
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12, ISelect select13) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12, ISelect select13, ISelect select14) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12, ISelect select13, ISelect select14, ISelect select15) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class;
+ ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12, ISelect select13, ISelect select14, ISelect select15, ISelect select16) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class;
+
ISelect UnionAll(params ISelect[] querys);
-
///
/// 查询条件,Where(a => a.Id > 10),支持导航对象查询,Where(a => a.Author.Email == "2881099@qq.com")
///
diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
index a220402a9..726701702 100644
--- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
+++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
@@ -210,7 +210,62 @@ public ISelect FromQuery(ISelect select2
var ret = From();
return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider });
}
-
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider, select9 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider, select9 as Select0Provider, select10 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider, select9 as Select0Provider, select10 as Select0Provider, select11 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider, select9 as Select0Provider, select10 as Select0Provider, select11 as Select0Provider, select12 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect select7, ISelect select8, ISelect select9, ISelect select10, ISelect select11, ISelect select12, ISelect select13) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
+ {
+ var ret = From();
+ return FromQueryMulti(ret, new[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12), typeof(T13) }, new[] { select2 as Select0Provider, select3 as Select0Provider, select4 as Select0Provider, select5 as Select0Provider, select6 as Select0Provider, select7 as Select0Provider, select8 as Select0Provider, select9 as Select0Provider, select10 as Select0Provider, select11 as Select0Provider, select12 as Select0Provider, select13 as Select0Provider });
+ }
+ public ISelect FromQuery(ISelect select2, ISelect select3, ISelect select4, ISelect select5, ISelect select6, ISelect