diff --git a/Examples/dbcontext_01/.config/dotnet-tools.json b/Examples/dbcontext_01/.config/dotnet-tools.json new file mode 100644 index 00000000..c735fef1 --- /dev/null +++ b/Examples/dbcontext_01/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "5.0.0", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/Examples/dbcontext_01/Properties/PublishProfiles/FolderProfile.pubxml b/Examples/dbcontext_01/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 00000000..d895b3b8 --- /dev/null +++ b/Examples/dbcontext_01/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,22 @@ + + + + + True + False + True + Release + Any CPU + FileSystem + bin\Release\net5.0\publish\ + FileSystem + + net5.0 + win-x86 + 690f89e0-a721-423f-8f5d-d262f73235ea + true + True + + \ No newline at end of file diff --git a/Examples/dbcontext_01/dbcontext_01.csproj b/Examples/dbcontext_01/dbcontext_01.csproj index 2b5846c8..46c1f9de 100644 --- a/Examples/dbcontext_01/dbcontext_01.csproj +++ b/Examples/dbcontext_01/dbcontext_01.csproj @@ -3,6 +3,11 @@ net5.0 InProcess + f2b3f543-99d4-4be7-b894-6df3c6cbad7e + + + + dbcontext_01.xml @@ -12,7 +17,7 @@ - + diff --git a/Examples/dbcontext_01/dbcontext_01.xml b/Examples/dbcontext_01/dbcontext_01.xml new file mode 100644 index 00000000..b9d14721 --- /dev/null +++ b/Examples/dbcontext_01/dbcontext_01.xml @@ -0,0 +1,8 @@ + + + + dbcontext_01 + + + + diff --git a/FreeSql/Extensions/AdoNetExtensions.cs b/FreeSql/Extensions/AdoNetExtensions.cs index b9f874ba..a4275d06 100644 --- a/FreeSql/Extensions/AdoNetExtensions.cs +++ b/FreeSql/Extensions/AdoNetExtensions.cs @@ -85,6 +85,7 @@ namespace FreeSql /// 插入数据,传入实体 /// /// + /// /// /// public static IInsert Insert(this IDbConnection that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); @@ -92,6 +93,7 @@ namespace FreeSql /// 插入数据,传入实体数组 /// /// + /// /// /// public static IInsert Insert(this IDbConnection that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); @@ -99,6 +101,7 @@ namespace FreeSql /// 插入数据,传入实体集合 /// /// + /// /// /// public static IInsert Insert(this IDbConnection that, List source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); @@ -106,6 +109,7 @@ namespace FreeSql /// 插入数据,传入实体集合 /// /// + /// /// /// public static IInsert Insert(this IDbConnection that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); @@ -125,6 +129,7 @@ namespace FreeSql /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) /// /// + /// /// public static IInsertOrUpdate InsertOrUpdate(this IDbConnection that) where T1 : class => GetCrud(that).InsertOrUpdate().WithConnection(that as DbConnection); @@ -132,12 +137,14 @@ namespace FreeSql /// 修改数据 /// /// + /// /// public static IUpdate Update(this IDbConnection that) where T1 : class => GetCrud(that).Update().WithConnection(that as DbConnection); /// /// 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IUpdate Update(this IDbConnection that, object dywhere) where T1 : class => GetCrud(that).Update(dywhere).WithConnection(that as DbConnection); @@ -146,12 +153,14 @@ namespace FreeSql /// 查询数据 /// /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class => GetCrud(that).Select().WithConnection(that as DbConnection); /// /// 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static ISelect Select(this IDbConnection that, object dywhere) where T1 : class => GetCrud(that).Select(dywhere).WithConnection(that as DbConnection); @@ -160,12 +169,14 @@ namespace FreeSql /// 删除数据 /// /// + /// /// public static IDelete Delete(this IDbConnection that) where T1 : class => GetCrud(that).Delete().WithConnection(that as DbConnection); /// /// 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IDelete Delete(this IDbConnection that, object dywhere) where T1 : class => GetCrud(that).Delete(dywhere).WithConnection(that as DbConnection); @@ -173,54 +184,63 @@ namespace FreeSql /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class => GetCrud(that).Select().From((s, b) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class => GetCrud(that).Select().From((s, b, c) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class => GetCrud(that).Select().From((s, b, c, d) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => GetCrud(that).Select().From((s, b, c, d, e) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => GetCrud(that).Select().From((s, b, c, d, e, f) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => GetCrud(that).Select().From((s, b, c, d, e, f, g) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class => GetCrud(that).Select().From((s, b, c, d, e, f, g, h) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class => GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i) => s); /// /// 多表查询 /// + /// /// public static ISelect Select(this IDbConnection that) where T1 : class 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 => GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i, j) => s); @@ -237,6 +257,7 @@ namespace FreeSql /// 插入数据,传入实体 /// /// + /// /// /// public static IInsert Insert(this IDbTransaction that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); @@ -244,6 +265,7 @@ namespace FreeSql /// 插入数据,传入实体数组 /// /// + /// /// /// public static IInsert Insert(this IDbTransaction that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); @@ -251,6 +273,7 @@ namespace FreeSql /// 插入数据,传入实体集合 /// /// + /// /// /// public static IInsert Insert(this IDbTransaction that, List source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); @@ -258,6 +281,7 @@ namespace FreeSql /// 插入数据,传入实体集合 /// /// + /// /// /// public static IInsert Insert(this IDbTransaction that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); @@ -276,6 +300,7 @@ namespace FreeSql /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) /// /// + /// /// public static IInsertOrUpdate InsertOrUpdate(this IDbTransaction that) where T1 : class => GetCrud(that).InsertOrUpdate().WithTransaction(that as DbTransaction); @@ -283,12 +308,14 @@ namespace FreeSql /// 修改数据 /// /// + /// /// public static IUpdate Update(this IDbTransaction that) where T1 : class => GetCrud(that).Update().WithTransaction(that as DbTransaction); /// /// 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IUpdate Update(this IDbTransaction that, object dywhere) where T1 : class => GetCrud(that).Update(dywhere).WithTransaction(that as DbTransaction); @@ -297,12 +324,14 @@ namespace FreeSql /// 查询数据 /// /// + /// /// public static ISelect Select(this IDbTransaction that) where T1 : class => GetCrud(that).Select().WithTransaction(that as DbTransaction); /// /// 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static ISelect Select(this IDbTransaction that, object dywhere) where T1 : class => GetCrud(that).Select(dywhere).WithTransaction(that as DbTransaction); @@ -311,12 +340,14 @@ namespace FreeSql /// 删除数据 /// /// + /// /// public static IDelete Delete(this IDbTransaction that) where T1 : class => GetCrud(that).Delete().WithTransaction(that as DbTransaction); /// /// 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// + /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IDelete Delete(this IDbTransaction that, object dywhere) where T1 : class => GetCrud(that).Delete(dywhere).WithTransaction(that as DbTransaction); diff --git a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs index 531a8f8b..79d62f2e 100644 --- a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs +++ b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs @@ -56,6 +56,7 @@ public static partial class FreeSqlGlobalExtensions /// 获取 Type 的原始 c# 文本表示 /// /// + /// /// internal static string DisplayCsharp(this Type type, bool isNameSpace = true) { @@ -88,14 +89,14 @@ public static partial class FreeSqlGlobalExtensions if (genericParameters.Any() == false) return sb.Append(type.Name).ToString(); - sb.Append(type.Name.Remove(type.Name.IndexOf('`'))).Append("<"); + sb.Append(type.Name.Remove(type.Name.IndexOf('`'))).Append('<'); var genericTypeIndex = 0; foreach (var genericType in genericParameters) { if (genericTypeIndex++ > 0) sb.Append(", "); sb.Append(DisplayCsharp(genericType, true)); } - return sb.Append(">").ToString(); + return sb.Append('>').ToString(); } internal static string DisplayCsharp(this MethodInfo method, bool isOverride) { @@ -109,7 +110,7 @@ public static partial class FreeSqlGlobalExtensions if (method.IsStatic) sb.Append("static "); if (method.IsAbstract && method.DeclaringType.IsInterface == false) sb.Append("abstract "); if (method.IsVirtual && method.DeclaringType.IsInterface == false) sb.Append(isOverride ? "override " : "virtual "); - sb.Append(method.ReturnType.DisplayCsharp()).Append(" ").Append(method.Name); + sb.Append(method.ReturnType.DisplayCsharp()).Append(' ').Append(method.Name); var genericParameters = method.GetGenericArguments(); if (method.DeclaringType.IsNested && method.DeclaringType.DeclaringType.IsGenericType) @@ -121,11 +122,11 @@ public static partial class FreeSqlGlobalExtensions genericParameters = dic.Values.ToArray(); } if (genericParameters.Any()) - sb.Append("<") + sb.Append('<') .Append(string.Join(", ", genericParameters.Select(a => a.DisplayCsharp()))) - .Append(">"); + .Append('>'); - sb.Append("(").Append(string.Join(", ", method.GetParameters().Select(a => $"{a.ParameterType.DisplayCsharp()} {a.Name}"))).Append(")"); + sb.Append('(').Append(string.Join(", ", method.GetParameters().Select(a => $"{a.ParameterType.DisplayCsharp()} {a.Name}"))).Append(')'); return sb.ToString(); } public static object CreateInstanceGetDefaultValue(this Type that) @@ -283,7 +284,10 @@ public static partial class FreeSqlGlobalExtensions /// 示例:new List<Song>(new[] { song1, song2, song3 }).IncludeMany(g.sqlite, a => a.Tags); /// 文档:https://github.com/2881099/FreeSql/wiki/%e8%b4%aa%e5%a9%aa%e5%8a%a0%e8%bd%bd#%E5%AF%BC%E8%88%AA%E5%B1%9E%E6%80%A7-onetomanymanytomany /// + /// /// + /// + /// /// 选择一个集合的导航属性,如: .IncludeMany(a => a.Tags) /// 可以 .Where 设置临时的关系映射,如: .IncludeMany(a => a.Tags.Where(tag => tag.TypeId == a.Id)) /// 可以 .Take(5) 每个子集合只取5条,如: .IncludeMany(a => a.Tags.Take(5)) @@ -538,7 +542,7 @@ JOIN {select._commonUtils.QuoteSqlName(tb.DbName)} a ON cte_tbc.cte_id = a.{sele .OrderBy(up, "a.cte_level desc") as Select1Provider; var nsselsb = new StringBuilder(); - if (AdoProvider.IsFromSlave(select._select) == false) nsselsb.Append(" "); //读写分离规则,如果强制读主库,则在前面加个空格 + if (AdoProvider.IsFromSlave(select._select) == false) nsselsb.Append(' '); //读写分离规则,如果强制读主库,则在前面加个空格 nsselsb.Append("WITH "); switch (select._orm.Ado.DataType) { diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 3632c4f9..5140edee 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -635,6 +635,7 @@ 插入数据,传入实体 + @@ -643,6 +644,7 @@ 插入数据,传入实体数组 + @@ -651,6 +653,7 @@ 插入数据,传入实体集合 + @@ -659,6 +662,7 @@ 插入数据,传入实体集合 + @@ -678,6 +682,7 @@ 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + @@ -685,6 +690,7 @@ 修改数据 + @@ -692,6 +698,7 @@ 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -700,6 +707,7 @@ 查询数据 + @@ -707,6 +715,7 @@ 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -715,6 +724,7 @@ 删除数据 + @@ -722,6 +732,7 @@ 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -729,54 +740,63 @@ 多表查询 + 多表查询 + 多表查询 + 多表查询 + 多表查询 + 多表查询 + 多表查询 + 多表查询 + 多表查询 + @@ -791,6 +811,7 @@ 插入数据,传入实体 + @@ -799,6 +820,7 @@ 插入数据,传入实体数组 + @@ -807,6 +829,7 @@ 插入数据,传入实体集合 + @@ -815,6 +838,7 @@ 插入数据,传入实体集合 + @@ -833,6 +857,7 @@ 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + @@ -840,6 +865,7 @@ 修改数据 + @@ -847,6 +873,7 @@ 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -855,6 +882,7 @@ 查询数据 + @@ -862,6 +890,7 @@ 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -870,6 +899,7 @@ 删除数据 + @@ -877,6 +907,7 @@ 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 @@ -2268,6 +2299,7 @@ + lambda表达式 @@ -2471,6 +2503,7 @@ 返回类型 选择列 + @@ -2925,6 +2958,7 @@ 查询,ExecuteReader(dr => {}, "select * from user where age > ?age", new { age = 25 }) 提示:parms 参数还可以传 Dictionary<string, object> + @@ -2932,6 +2966,7 @@ 查询 + @@ -2948,6 +2983,7 @@ 查询 + @@ -2964,6 +3000,7 @@ 查询 + @@ -3035,6 +3072,7 @@ 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) + @@ -3046,6 +3084,7 @@ 提示:parms 参数还可以传 Dictionary<string, object> + @@ -3057,6 +3096,7 @@ Oracle: SELECT 1 FROM dual 命令超时设置(秒) + true: 成功, false: 失败 @@ -3067,21 +3107,26 @@ + 查询,ExecuteReaderAsync(dr => {}, "select * from user where age > ?age", new { age = 25 }) 提示:parms 参数还可以传 Dictionary<string, object> + + 查询 + + @@ -3090,14 +3135,17 @@ + 查询 + + @@ -3106,14 +3154,17 @@ + 查询 + + @@ -3122,6 +3173,7 @@ + @@ -3131,6 +3183,7 @@ + @@ -3139,6 +3192,7 @@ + @@ -3148,6 +3202,7 @@ + @@ -3156,6 +3211,7 @@ + @@ -3166,6 +3222,7 @@ + @@ -3176,6 +3233,7 @@ + @@ -3183,9 +3241,11 @@ 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) + + @@ -3194,8 +3254,10 @@ 提示:parms 参数还可以传 Dictionary<string, object> + + @@ -4317,6 +4379,7 @@ 获取 Type 的原始 c# 文本表示 + @@ -4347,7 +4410,10 @@ 示例:new List<Song>(new[] { song1, song2, song3 }).IncludeMany(g.sqlite, a => a.Tags); 文档:https://github.com/2881099/FreeSql/wiki/%e8%b4%aa%e5%a9%aa%e5%8a%a0%e8%bd%bd#%E5%AF%BC%E8%88%AA%E5%B1%9E%E6%80%A7-onetomanymanytomany + + + 选择一个集合的导航属性,如: .IncludeMany(a => a.Tags) 可以 .Where 设置临时的关系映射,如: .IncludeMany(a => a.Tags.Where(tag => tag.TypeId == a.Id)) 可以 .Take(5) 每个子集合只取5条,如: .IncludeMany(a => a.Tags.Take(5)) diff --git a/FreeSql/Interface/Curd/ISelect/ISelect1.cs b/FreeSql/Interface/Curd/ISelect/ISelect1.cs index 4bff2524..d2537fcb 100644 --- a/FreeSql/Interface/Curd/ISelect/ISelect1.cs +++ b/FreeSql/Interface/Curd/ISelect/ISelect1.cs @@ -242,6 +242,7 @@ namespace FreeSql /// /// /// + /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class where T5 : class; diff --git a/FreeSql/Interface/Curd/ISelect/ISelectGrouping.cs b/FreeSql/Interface/Curd/ISelect/ISelectGrouping.cs index 1e311a29..295b7411 100644 --- a/FreeSql/Interface/Curd/ISelect/ISelectGrouping.cs +++ b/FreeSql/Interface/Curd/ISelect/ISelectGrouping.cs @@ -57,6 +57,7 @@ namespace FreeSql /// /// 返回类型 /// 选择列 + /// /// string ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias = FieldAliasOptions.AsIndex); /// diff --git a/FreeSql/Interface/IAdo.cs b/FreeSql/Interface/IAdo.cs index 7e8f53f1..56855659 100644 --- a/FreeSql/Interface/IAdo.cs +++ b/FreeSql/Interface/IAdo.cs @@ -101,6 +101,7 @@ namespace FreeSql /// 查询,ExecuteReader(dr => {}, "select * from user where age > ?age", new { age = 25 }) /// 提示:parms 参数还可以传 Dictionary<string, object> /// + /// /// /// void ExecuteReader(Action> fetchHandler, string cmdText, object parms = null); @@ -109,6 +110,7 @@ namespace FreeSql /// /// 查询 /// + /// /// /// object[][] ExecuteArray(CommandType cmdType, string cmdText, params DbParameter[] cmdParms); @@ -127,6 +129,7 @@ namespace FreeSql /// /// 查询 /// + /// /// /// DataSet ExecuteDataSet(CommandType cmdType, string cmdText, params DbParameter[] cmdParms); @@ -145,6 +148,7 @@ namespace FreeSql /// /// 查询 /// + /// /// /// DataTable ExecuteDataTable(CommandType cmdType, string cmdText, params DbParameter[] cmdParms); @@ -227,6 +231,7 @@ namespace FreeSql /// 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) /// /// + /// /// /// /// @@ -239,6 +244,7 @@ namespace FreeSql /// 提示:parms 参数还可以传 Dictionary<string, object> /// /// + /// /// /// /// @@ -274,6 +280,7 @@ namespace FreeSql /// Oracle: SELECT 1 FROM dual /// /// 命令超时设置(秒) + /// /// true: 成功, false: 失败 Task ExecuteConnectTestAsync(int commandTimeout = 0, CancellationToken cancellationToken = default); @@ -284,6 +291,7 @@ namespace FreeSql /// /// /// + /// Task ExecuteReaderAsync(Func, Task> readerHander, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteReaderAsync(DbTransaction transaction, Func, Task> readerHander, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteReaderAsync(DbConnection connection, DbTransaction transaction, Func, Task> readerHander, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -291,16 +299,20 @@ namespace FreeSql /// 查询,ExecuteReaderAsync(dr => {}, "select * from user where age > ?age", new { age = 25 }) /// 提示:parms 参数还可以传 Dictionary<string, object> /// + /// /// /// + /// Task ExecuteReaderAsync(Func, Task> readerHander, string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteReaderAsync(DbTransaction transaction, Func, Task> readerHander, string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteReaderAsync(DbConnection connection, DbTransaction transaction, Func, Task> readerHander, string cmdText, object parms = null, CancellationToken cancellationToken = default); /// /// 查询 /// + /// /// /// + /// Task ExecuteArrayAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteArrayAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteArrayAsync(DbConnection connection, DbTransaction transaction, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -310,6 +322,7 @@ namespace FreeSql /// /// /// + /// /// Task ExecuteArrayAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteArrayAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -317,8 +330,10 @@ namespace FreeSql /// /// 查询 /// + /// /// /// + /// Task ExecuteDataSetAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteDataSetAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteDataSetAsync(DbConnection connection, DbTransaction transaction, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -328,6 +343,7 @@ namespace FreeSql /// /// /// + /// /// Task ExecuteDataSetAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteDataSetAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -335,8 +351,10 @@ namespace FreeSql /// /// 查询 /// + /// /// /// + /// Task ExecuteDataTableAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteDataTableAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteDataTableAsync(DbConnection connection, DbTransaction transaction, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -346,6 +364,7 @@ namespace FreeSql /// /// /// + /// /// Task ExecuteDataTableAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteDataTableAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -356,6 +375,7 @@ namespace FreeSql /// /// /// + /// Task ExecuteNonQueryAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteNonQueryAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteNonQueryAsync(DbConnection connection, DbTransaction transaction, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -365,6 +385,7 @@ namespace FreeSql /// /// /// + /// /// Task ExecuteNonQueryAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteNonQueryAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -375,6 +396,7 @@ namespace FreeSql /// /// /// + /// Task ExecuteScalarAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteScalarAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task ExecuteScalarAsync(DbConnection connection, DbTransaction transaction, CommandType cmdType, string cmdText, int cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -384,6 +406,7 @@ namespace FreeSql /// /// /// + /// /// Task ExecuteScalarAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task ExecuteScalarAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -396,6 +419,7 @@ namespace FreeSql /// /// /// + /// /// Task> QueryAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task> QueryAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -408,6 +432,7 @@ namespace FreeSql /// /// /// + /// /// Task> QueryAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task> QueryAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); @@ -417,9 +442,11 @@ namespace FreeSql /// 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) /// /// + /// /// /// /// + /// /// Task, List>> QueryAsync(CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); Task, List>> QueryAsync(DbTransaction transaction, CommandType cmdType, string cmdText, DbParameter[] cmdParms, CancellationToken cancellationToken = default); @@ -429,8 +456,10 @@ namespace FreeSql /// 提示:parms 参数还可以传 Dictionary<string, object> /// /// + /// /// /// + /// /// Task, List>> QueryAsync(string cmdText, object parms = null, CancellationToken cancellationToken = default); Task, List>> QueryAsync(DbTransaction transaction, string cmdText, object parms = null, CancellationToken cancellationToken = default); diff --git a/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderTransaction.cs b/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderTransaction.cs index 2ea6f90c..e728e02d 100644 --- a/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderTransaction.cs +++ b/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderTransaction.cs @@ -57,7 +57,7 @@ namespace FreeSql.Internal.CommonProvider MasterPool.Return(conn); var after = new Aop.TraceAfterEventArgs(before, "", ex); _util?._orm?.Aop.TraceAfterHandler?.Invoke(this, after); - throw ex; + throw; } if (_trans.ContainsKey(tid)) CommitTransaction(); _trans.TryAdd(tid, tran); @@ -122,7 +122,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { if (requireTran) RollbackTransaction(ex); - throw ex; + throw; } } diff --git a/FreeSql/Internal/CommonProvider/CodeFirstProvider.cs b/FreeSql/Internal/CommonProvider/CodeFirstProvider.cs index bff2baa9..2ce2889e 100644 --- a/FreeSql/Internal/CommonProvider/CodeFirstProvider.cs +++ b/FreeSql/Internal/CommonProvider/CodeFirstProvider.cs @@ -119,7 +119,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { diff --git a/FreeSql/Internal/CommonProvider/DeleteProvider.cs b/FreeSql/Internal/CommonProvider/DeleteProvider.cs index 69eb0b82..e6530fd5 100644 --- a/FreeSql/Internal/CommonProvider/DeleteProvider.cs +++ b/FreeSql/Internal/CommonProvider/DeleteProvider.cs @@ -80,7 +80,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -102,7 +102,7 @@ namespace FreeSql.Internal.CommonProvider { if (string.IsNullOrEmpty(sql)) return this; if (++_whereTimes > 1) _where.Append(" AND "); - _where.Append("(").Append(sql).Append(")"); + _where.Append('(').Append(sql).Append(')'); if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms)); return this; } diff --git a/FreeSql/Internal/CommonProvider/DeleteProviderAsync.cs b/FreeSql/Internal/CommonProvider/DeleteProviderAsync.cs index 64af2765..85073150 100644 --- a/FreeSql/Internal/CommonProvider/DeleteProviderAsync.cs +++ b/FreeSql/Internal/CommonProvider/DeleteProviderAsync.cs @@ -30,7 +30,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { diff --git a/FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs b/FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs index 270dc44e..5c585114 100644 --- a/FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs +++ b/FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs @@ -254,7 +254,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -282,7 +282,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -308,7 +308,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -360,7 +360,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } diff --git a/FreeSql/Internal/CommonProvider/InsertProvider.cs b/FreeSql/Internal/CommonProvider/InsertProvider.cs index 2862a900..04cd04b2 100644 --- a/FreeSql/Internal/CommonProvider/InsertProvider.cs +++ b/FreeSql/Internal/CommonProvider/InsertProvider.cs @@ -269,7 +269,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -278,7 +278,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -350,7 +350,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -359,7 +359,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -429,7 +429,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -438,7 +438,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -464,7 +464,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -538,7 +538,7 @@ namespace FreeSql.Internal.CommonProvider { if (_source == null || _source.Any() == false) return null; var sb = new StringBuilder(); - sb.Append("INSERT INTO ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append("("); + sb.Append("INSERT INTO ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append('('); var colidx = 0; foreach (var col in _table.Columns.Values) { @@ -582,7 +582,7 @@ namespace FreeSql.Internal.CommonProvider } ++colidx2; } - if (isValues) sb.Append(")"); + if (isValues) sb.Append(')'); onrow?.Invoke(d, didx, sb); ++didx; } diff --git a/FreeSql/Internal/CommonProvider/InsertProviderAsync.cs b/FreeSql/Internal/CommonProvider/InsertProviderAsync.cs index b1123aa7..828dba7d 100644 --- a/FreeSql/Internal/CommonProvider/InsertProviderAsync.cs +++ b/FreeSql/Internal/CommonProvider/InsertProviderAsync.cs @@ -76,7 +76,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -85,7 +85,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -157,7 +157,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -166,7 +166,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -236,7 +236,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -245,7 +245,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -270,7 +270,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select0ProviderReader.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select0ProviderReader.cs index ca961a7f..954eb0fc 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select0ProviderReader.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select0ProviderReader.cs @@ -35,7 +35,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -72,7 +72,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -107,7 +107,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -175,7 +175,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -244,7 +244,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -291,7 +291,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -327,7 +327,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -741,7 +741,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -767,7 +767,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -817,7 +817,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -855,7 +855,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -892,7 +892,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -946,7 +946,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -983,7 +983,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -1040,7 +1040,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -1066,7 +1066,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { diff --git a/FreeSql/Internal/CommonProvider/UpdateProvider.cs b/FreeSql/Internal/CommonProvider/UpdateProvider.cs index ef22fe9c..2f8aed58 100644 --- a/FreeSql/Internal/CommonProvider/UpdateProvider.cs +++ b/FreeSql/Internal/CommonProvider/UpdateProvider.cs @@ -215,7 +215,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -224,7 +224,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -289,7 +289,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -298,7 +298,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -327,7 +327,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -555,7 +555,7 @@ namespace FreeSql.Internal.CommonProvider public IUpdate Where(string sql, object parms = null) { if (string.IsNullOrEmpty(sql)) return this; - _where.Append(" AND (").Append(sql).Append(")"); + _where.Append(" AND (").Append(sql).Append(')'); if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms)); return this; } @@ -587,7 +587,7 @@ namespace FreeSql.Internal.CommonProvider { if (_source.Any() == false) return null; if (_table.ColumnsByCs.ContainsKey(CsName) == false) throw new Exception($"找不到 {CsName} 对应的列"); - if (thenValue == null) throw new ArgumentNullException("thenValue 参数不可为 null"); + if (thenValue == null) throw new ArgumentNullException(nameof(thenValue)); if (_source.Count == 0) return null; if (_source.Count == 1) @@ -626,7 +626,7 @@ namespace FreeSql.Internal.CommonProvider } cwsb.Append(" END"); if (nulls == _source.Count) sb.Append("NULL"); - else sb.Append(cwsb.ToString()); + else sb.Append(cwsb); cwsb.Clear(); return sb.ToString(); @@ -752,7 +752,7 @@ namespace FreeSql.Internal.CommonProvider else { ToSqlCaseWhenEnd(cwsb, col); - sb.Append(cwsb.ToString()); + sb.Append(cwsb); } cwsb.Clear(); } @@ -790,7 +790,7 @@ namespace FreeSql.Internal.CommonProvider if (_source.Any()) { if (_table.Primarys.Any() == false) throw new ArgumentException($"{_table.Type.DisplayCsharp()} 没有定义主键,无法使用 SetSource,请尝试 SetDto"); - sb.Append("(").Append(_commonUtils.WhereItems(_table, "", _source)).Append(")"); + sb.Append('(').Append(_commonUtils.WhereItems(_table, "", _source)).Append(')'); } if (_where.Length > 0) diff --git a/FreeSql/Internal/CommonProvider/UpdateProviderAsync.cs b/FreeSql/Internal/CommonProvider/UpdateProviderAsync.cs index 55599457..32e97a6c 100644 --- a/FreeSql/Internal/CommonProvider/UpdateProviderAsync.cs +++ b/FreeSql/Internal/CommonProvider/UpdateProviderAsync.cs @@ -72,7 +72,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -81,7 +81,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -145,7 +145,7 @@ namespace FreeSql.Internal.CommonProvider { _transaction.Rollback(); _orm.Aop.TraceAfterHandler?.Invoke(this, new Aop.TraceAfterEventArgs(transBefore, "回滚", ex)); - throw ex; + throw; } _transaction = null; } @@ -154,7 +154,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { @@ -182,7 +182,7 @@ namespace FreeSql.Internal.CommonProvider catch (Exception ex) { exception = ex; - throw ex; + throw; } finally { diff --git a/FreeSql/Internal/CommonUtils.cs b/FreeSql/Internal/CommonUtils.cs index 37963385..bc7e6f7b 100644 --- a/FreeSql/Internal/CommonUtils.cs +++ b/FreeSql/Internal/CommonUtils.cs @@ -14,6 +14,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.XPath; @@ -297,7 +298,7 @@ namespace FreeSql.Internal foreach (var i in ie) { isAny = true; - if (ieidx > 0) sb.Append(","); + if (ieidx > 0) sb.Append(','); if (ieidx == 0) { var itype = i.GetType(); @@ -308,7 +309,7 @@ namespace FreeSql.Internal ++ieidx; } if (isAny == false) return ""; - sb.Append(")"); + sb.Append(')'); return sb.ToString(); } else if (dywhere is IEnumerable) @@ -361,7 +362,7 @@ namespace FreeSql.Internal var indt = its.Select(a => pk1.GetDbValue(a)).Where(a => a != null).ToArray(); if (indt.Any() == false) return null; if (indt.Length == 1) sbin.Append(" = ").Append(GetNoneParamaterSqlValue(null, null, pk1, pk1.Attribute.MapType, indt.First())); - else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => GetNoneParamaterSqlValue(null, null, pk1, pk1.Attribute.MapType, a)))).Append(")"); + else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => GetNoneParamaterSqlValue(null, null, pk1, pk1.Attribute.MapType, a)))).Append(')'); return sbin.ToString(); } var dicpk = its.Length > 5 ? new Dictionary() : null; @@ -377,7 +378,7 @@ namespace FreeSql.Internal { sb.Append(" OR ("); sb.Append(filter.Substring(5)); - sb.Append(")"); + sb.Append(')'); ++iidx; } if (dicpk != null) @@ -399,7 +400,7 @@ namespace FreeSql.Internal { sb.Append(" OR ("); sb.Append(fil.Key); - sb.Append(")"); + sb.Append(')'); } } return iidx == 1 ? sb.Remove(0, 5).Remove(sb.Length - 1, 1).ToString() : sb.Remove(0, 4).ToString(); @@ -447,6 +448,7 @@ namespace FreeSql.Internal } } + static int _CodeBaseNotSupportedException = 0; /// /// 通过属性的注释文本,通过 xml 读取 /// @@ -464,7 +466,17 @@ namespace FreeSql.Internal var xmlPath = regex.Replace(localType.Assembly.Location, ".xml"); if (File.Exists(xmlPath) == false) { - if (string.IsNullOrEmpty(localType.Assembly.CodeBase)) return null; + if (_CodeBaseNotSupportedException == 1) return null; + try + { + if (string.IsNullOrEmpty(localType.Assembly.CodeBase)) return null; + } + catch (NotSupportedException) //NotSupportedException: CodeBase is not supported on assemblies loaded from a single-file bundle. + { + Interlocked.Exchange(ref _CodeBaseNotSupportedException, 1); + return null; + } + xmlPath = regex.Replace(localType.Assembly.CodeBase, ".xml"); if (xmlPath.StartsWith("file:///") && Uri.TryCreate(xmlPath, UriKind.Absolute, out var tryuri)) xmlPath = tryuri.LocalPath;