diff --git a/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.csproj b/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.csproj deleted file mode 100644 index 693e24bf..00000000 --- a/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - netstandard2.0;net45;net40 - 1.8.0-preview0815 - true - FreeSql;ncc;YeXiangQin - FreeSql AdoNet 扩展包,增加 IDbConnection/IDbTransaction 对象的扩展方法 Select/Insert/Update/Delete 实现 CRUD。 - https://github.com/2881099/FreeSql - https://github.com/2881099/FreeSql - git - MIT - FreeSql;ORM - $(AssemblyName) - logo.png - $(AssemblyName) - true - true - true - key.snk - false - - - - - - - - FreeSql.Extensions.AdoNet.xml - 3 - - - - - - - diff --git a/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.xml b/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.xml deleted file mode 100644 index c05792be..00000000 --- a/Extensions/FreeSql.Extensions.AdoNet/FreeSql.Extensions.AdoNet.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - FreeSql.Extensions.AdoNet - - - - - 获取 IDbConnection 对应的 IFreeSql 实例 - - - - - - - 插入数据 - - - - - - - 插入数据,传入实体 - - - - - - - - 插入数据,传入实体数组 - - - - - - - - 插入数据,传入实体集合 - - - - - - - - 插入数据,传入实体集合 - - - - - - - - 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: - 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 - 达梦: 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} - - - 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 - - - - - 插入数据 - - - - - - - 插入数据,传入实体 - - - - - - - - 插入数据,传入实体数组 - - - - - - - - 插入数据,传入实体集合 - - - - - - - - 插入数据,传入实体集合 - - - - - - - - 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: - 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 - 达梦: 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} - - - 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 - - - - diff --git a/Extensions/FreeSql.Extensions.AdoNet/FreeSqlAdoNetExtensions.cs b/Extensions/FreeSql.Extensions.AdoNet/FreeSqlAdoNetExtensions.cs deleted file mode 100644 index e79b09f3..00000000 --- a/Extensions/FreeSql.Extensions.AdoNet/FreeSqlAdoNetExtensions.cs +++ /dev/null @@ -1,265 +0,0 @@ -using FreeSql; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; - -public static class FreeSqlAdoNetExtensions -{ - static Dictionary _dicCurd = new Dictionary(); - static object _dicCurdLock = new object(); - static IFreeSql GetCrud(IDbConnection dbconn) - { - if (dbconn == null) throw new ArgumentNullException($"{nameof(dbconn)} 不能为 null"); ; - Type dbconType = dbconn.GetType(); - var connType = dbconType.UnderlyingSystemType; - if (_dicCurd.TryGetValue(connType, out var fsql)) return fsql; - - Type providerType = null; - switch (connType.Name) - { - case "MySqlConnection": - providerType = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySql")?.MakeGenericType(connType); - if (providerType == null) providerType = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.MySql.dll,可前往 nuget 下载"); - break; - case "SqlConnection": - providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.SqlServer.dll,可前往 nuget 下载"); - break; - case "NpgsqlConnection": - providerType = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.PostgreSQL.dll,可前往 nuget 下载"); - break; - case "OracleConnection": - providerType = Type.GetType("FreeSql.Oracle.OracleProvider`1,FreeSql.Provider.Oracle")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Oracle.dll,可前往 nuget 下载"); - break; - case "SQLiteConnection": - providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.Sqlite")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Sqlite.dll,可前往 nuget 下载"); - break; - case "DmConnection": - providerType = Type.GetType("FreeSql.Dameng.DamengProvider`1,FreeSql.Provider.Dameng")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Dameng.dll,可前往 nuget 下载"); - break; - case "OscarConnection": - providerType = Type.GetType("FreeSql.ShenTong.ShenTongProvider`1,FreeSql.Provider.ShenTong")?.MakeGenericType(connType); - if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.ShenTong.dll,可前往 nuget 下载"); - break; - default: - throw new Exception("未实现"); - } - lock (_dicCurdLock) - { - if (_dicCurd.TryGetValue(connType, out fsql)) return fsql; - lock (_dicCurdLock) - _dicCurd.Add(connType, fsql = Activator.CreateInstance(providerType, new object[] { null, null, null }) as IFreeSql); - } - return fsql; - } - static IFreeSql GetCrud(IDbTransaction dbtran) - { - if (dbtran == null) throw new ArgumentNullException($"{nameof(dbtran)} 不能为 null"); - return GetCrud(dbtran.Connection); - } - - /// - /// 获取 IDbConnection 对应的 IFreeSql 实例 - /// - /// - /// - public static IFreeSql GetIFreeSql(this IDbConnection that) => GetCrud(that); - - #region IDbConnection - /// - /// 插入数据 - /// - /// - /// - public static IInsert Insert(this IDbConnection that) where T1 : class => GetCrud(that).Insert().WithConnection(that as DbConnection); - /// - /// 插入数据,传入实体 - /// - /// - /// - /// - public static IInsert Insert(this IDbConnection that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); - /// - /// 插入数据,传入实体数组 - /// - /// - /// - /// - public static IInsert Insert(this IDbConnection that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); - /// - /// 插入数据,传入实体集合 - /// - /// - /// - /// - public static IInsert Insert(this IDbConnection that, List source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); - /// - /// 插入数据,传入实体集合 - /// - /// - /// - /// - public static IInsert Insert(this IDbConnection that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); - - /// - /// 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: - /// 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 - /// 达梦: merge into - /// 人大金仓:on conflict do update - /// 神通:merge into - /// MsAccess:不支持 - /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) - /// - /// - /// - public static IInsertOrUpdate InsertOrUpdate(this IDbConnection that) where T1 : class => GetCrud(that).InsertOrUpdate().WithConnection(that as DbConnection); - - /// - /// 修改数据 - /// - /// - /// - 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); - - /// - /// 查询数据 - /// - /// - /// - 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); - - /// - /// 删除数据 - /// - /// - /// - 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); - #endregion - - #region IDbTransaction - /// - /// 插入数据 - /// - /// - /// - public static IInsert Insert(this IDbTransaction that) where T1 : class => GetCrud(that).Insert().WithTransaction(that as DbTransaction); - /// - /// 插入数据,传入实体 - /// - /// - /// - /// - public static IInsert Insert(this IDbTransaction that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); - /// - /// 插入数据,传入实体数组 - /// - /// - /// - /// - public static IInsert Insert(this IDbTransaction that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); - /// - /// 插入数据,传入实体集合 - /// - /// - /// - /// - public static IInsert Insert(this IDbTransaction that, List source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); - /// - /// 插入数据,传入实体集合 - /// - /// - /// - /// - public static IInsert Insert(this IDbTransaction that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); - - /// - /// 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: - /// 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 - /// 达梦: merge into - /// 人大金仓:on conflict do update - /// 神通:merge into - /// MsAccess:不支持 - /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) - /// - /// - /// - public static IInsertOrUpdate InsertOrUpdate(this IDbTransaction that) where T1 : class => GetCrud(that).InsertOrUpdate().WithTransaction(that as DbTransaction); - - /// - /// 修改数据 - /// - /// - /// - 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); - - /// - /// 查询数据 - /// - /// - /// - 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); - - /// - /// 删除数据 - /// - /// - /// - 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); - #endregion -} \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.AdoNet/key.snk b/Extensions/FreeSql.Extensions.AdoNet/key.snk deleted file mode 100644 index e580bc8d..00000000 Binary files a/Extensions/FreeSql.Extensions.AdoNet/key.snk and /dev/null differ diff --git a/Extensions/FreeSql.Extensions.AdoNet/readme.md b/Extensions/FreeSql.Extensions.AdoNet/readme.md deleted file mode 100644 index a7ad6912..00000000 --- a/Extensions/FreeSql.Extensions.AdoNet/readme.md +++ /dev/null @@ -1,23 +0,0 @@ -FreeSql AdoNet 扩展包,增加 IDbConnection/IDbTransaction 对象的扩展方法 Select/Insert/Update/Delete 实现 CRUD。 - -## 如果在 abp-vnext 中使用? - -本方法依赖 Volo.Abp.Dapper,所以也依赖 Volo.Abp.EntityFrameworkCore - -提示:FreeSql 兼容 EFCore 99% 的实体特性 - -> dotnet add package FreeSql.Extensions.AdoNet - -```csharp -IDapperRepository repo = ...; - -repo.DbConnection.Select().Where(...).ToList(); - -repo.DbConnection.Insert(new T {}).ExecuteAffrows(); - -repo.DbConnection.Update().SetSource(new T {}).ExecuteAffrows(); - -repo.DbConnection.Delete().Where(...).ExecuteAffrows(); - -IFreeSql fsql = repo.DbConnection.GetFreeSql(); //获取 IFreeSql 实例 -``` diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/FreeSql.Tests.Extensions.AdoNet.csproj b/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/FreeSql.Tests.Extensions.AdoNet.csproj deleted file mode 100644 index 09688700..00000000 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/FreeSql.Tests.Extensions.AdoNet.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - netcoreapp3.1 - false - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/g.cs b/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/g.cs deleted file mode 100644 index de01953d..00000000 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/g.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Diagnostics; - - -public class g { - - static Lazy sqlserverLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10") - .UseAutoSyncStructure(true) - .UseMonitorCommand( - cmd => { - Trace.WriteLine(cmd.CommandText); - }, //监听SQL命令对象,在执行前 - (cmd, traceLog) => { - Console.WriteLine(traceLog); - }) //监听SQL命令对象,在执行后 - .UseLazyLoading(true) - .Build()); - public static IFreeSql sqlserver => sqlserverLazy.Value; - - static Lazy mysqlLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10") - .UseAutoSyncStructure(true) - .UseMonitorCommand( - cmd => { - Trace.WriteLine(cmd.CommandText); - }, //监听SQL命令对象,在执行前 - (cmd, traceLog) => { - Console.WriteLine(traceLog); - }) //监听SQL命令对象,在执行后 - .UseLazyLoading(true) - .Build()); - public static IFreeSql mysql => mysqlLazy.Value; - - static Lazy pgsqlLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=10") - .UseAutoSyncStructure(true) - .UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) - .UseLazyLoading(true) - .UseMonitorCommand( - cmd => { - Trace.WriteLine(cmd.CommandText); - }, //监听SQL命令对象,在执行前 - (cmd, traceLog) => { - Console.WriteLine(traceLog); - }) //监听SQL命令对象,在执行后 - .Build()); - public static IFreeSql pgsql => pgsqlLazy.Value; - - static Lazy oracleLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=10") - .UseAutoSyncStructure(true) - .UseLazyLoading(true) - .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) - //.UseNoneCommandParameter(true) - - .UseMonitorCommand( - cmd => { - Trace.WriteLine(cmd.CommandText); - }, //监听SQL命令对象,在执行前 - (cmd, traceLog) => { - Console.WriteLine(traceLog); - }) //监听SQL命令对象,在执行后 - .Build()); - public static IFreeSql oracle = oracleLazy.Value; - - static Lazy sqliteLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Attachs=xxxtb.db;Pooling=true;Max Pool Size=10") - .UseAutoSyncStructure(true) - .UseLazyLoading(true) - .UseMonitorCommand( - cmd => { - Trace.WriteLine(cmd.CommandText); - }, //监听SQL命令对象,在执行前 - (cmd, traceLog) => { - Console.WriteLine(traceLog); - }) //监听SQL命令对象,在执行后 - .Build()); - public static IFreeSql sqlite = sqliteLazy.Value; -} diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/MySqlConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs similarity index 97% rename from FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/MySqlConnectionExtensionsTest.cs rename to FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs index 367fdd53..c16eb020 100644 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/MySqlConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using Xunit; -namespace Tests.MySqlConnectionExtensions { +namespace FreeSql.Tests.AdoNetExtensions.MySqlConnectionExtensions { public class Methods { string _connectString = "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=5"; diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/NpgsqlConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/NpgsqlConnectionExtensionsTest.cs similarity index 96% rename from FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/NpgsqlConnectionExtensionsTest.cs rename to FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/NpgsqlConnectionExtensionsTest.cs index 26acbcf6..18b70be9 100644 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/NpgsqlConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/NpgsqlConnectionExtensionsTest.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using Xunit; -namespace Tests.NpgsqlConnectionExtensions { +namespace FreeSql.Tests.AdoNetExtensions.NpgsqlConnectionExtensions { public class Methods { string _connectString = "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=5"; diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/OracleConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/OracleConnectionExtensionsTest.cs similarity index 96% rename from FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/OracleConnectionExtensionsTest.cs rename to FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/OracleConnectionExtensionsTest.cs index c838f938..faec49a6 100644 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/OracleConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/OracleConnectionExtensionsTest.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using Xunit; -namespace Tests.OracleConnectionExtensions { +namespace FreeSql.Tests.AdoNetExtensions.OracleConnectionExtensions { public class Methods { string _connectString = "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=5"; diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SQLiteConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SQLiteConnectionExtensionsTest.cs similarity index 96% rename from FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SQLiteConnectionExtensionsTest.cs rename to FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SQLiteConnectionExtensionsTest.cs index 77c2dd7c..9ee8faa0 100644 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SQLiteConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SQLiteConnectionExtensionsTest.cs @@ -5,7 +5,7 @@ using System.Data.Common; using System.Data.SQLite; using Xunit; -namespace Tests.SQLiteConnectionExtensions { +namespace FreeSql.Tests.AdoNetExtensions.SQLiteConnectionExtensions { public class Methods { string _connectString = "Data Source=|DataDirectory|/document.db;Attachs=xxxtb.db;Pooling=true;Max Pool Size=5"; diff --git a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SqlConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SqlConnectionExtensionsTest.cs similarity index 97% rename from FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SqlConnectionExtensionsTest.cs rename to FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SqlConnectionExtensionsTest.cs index e7f4329f..ca6a80ea 100644 --- a/FreeSql.Tests/FreeSql.Tests.Extensions.AdoNet/SqlConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/SqlConnectionExtensionsTest.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Microsoft.Data.SqlClient; using Xunit; -namespace Tests.SqlConnectionExtensions { +namespace FreeSql.Tests.AdoNetExtensions.SqlConnectionExtensions { public class Methods { string _connectString = "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=5"; diff --git a/FreeSql.sln b/FreeSql.sln index 8ca3a57a..e1c05120 100644 --- a/FreeSql.sln +++ b/FreeSql.sln @@ -86,10 +86,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Post EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.SqlServerForSystem", "Providers\FreeSql.Provider.SqlServerForSystem\FreeSql.Provider.SqlServerForSystem.csproj", "{3D2BD8EC-253A-437F-B4C8-74BC0D91429B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.AdoNet", "Extensions\FreeSql.Extensions.AdoNet\FreeSql.Extensions.AdoNet.csproj", "{774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Extensions.AdoNet", "FreeSql.Tests\FreeSql.Tests.Extensions.AdoNet\FreeSql.Tests.Extensions.AdoNet.csproj", "{02B31331-9B6E-44D2-B135-38DAE92F8A40}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -532,30 +528,6 @@ Global {3D2BD8EC-253A-437F-B4C8-74BC0D91429B}.Release|x64.Build.0 = Release|Any CPU {3D2BD8EC-253A-437F-B4C8-74BC0D91429B}.Release|x86.ActiveCfg = Release|Any CPU {3D2BD8EC-253A-437F-B4C8-74BC0D91429B}.Release|x86.Build.0 = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|x64.ActiveCfg = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|x64.Build.0 = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|x86.ActiveCfg = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Debug|x86.Build.0 = Debug|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|Any CPU.Build.0 = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|x64.ActiveCfg = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|x64.Build.0 = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|x86.ActiveCfg = Release|Any CPU - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD}.Release|x86.Build.0 = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|x64.ActiveCfg = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|x64.Build.0 = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|x86.ActiveCfg = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Debug|x86.Build.0 = Debug|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|Any CPU.Build.0 = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|x64.ActiveCfg = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|x64.Build.0 = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|x86.ActiveCfg = Release|Any CPU - {02B31331-9B6E-44D2-B135-38DAE92F8A40}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -586,7 +558,6 @@ Global {07AB0B37-A8B1-4FB1-9259-7B804E369E36} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B} {938173AF-157F-4040-AED3-171DA1809CAA} = {2A381C57-2697-427B-9F10-55DA11FD02E4} {3D2BD8EC-253A-437F-B4C8-74BC0D91429B} = {2A381C57-2697-427B-9F10-55DA11FD02E4} - {774A7AAD-60F2-40E2-93E1-E74FC2C1BBFD} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98} diff --git a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs index 416646bc..e72c637b 100644 --- a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs +++ b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs @@ -7,6 +7,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Data.Common; using System.Drawing; using System.Linq; using System.Linq.Expressions; @@ -511,4 +512,265 @@ SELECT "); return newSelect; } #endregion + + #region Ado.net 扩展方法,类似于 Dapper + + static Dictionary _dicCurd = new Dictionary(); + static object _dicCurdLock = new object(); + static IFreeSql GetCrud(IDbConnection dbconn) + { + if (dbconn == null) throw new ArgumentNullException($"{nameof(dbconn)} 不能为 null"); ; + Type dbconType = dbconn.GetType(); + var connType = dbconType.UnderlyingSystemType; + if (_dicCurd.TryGetValue(connType, out var fsql)) return fsql; + + Type providerType = null; + switch (connType.Name) + { + case "MySqlConnection": + providerType = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySql")?.MakeGenericType(connType); + if (providerType == null) providerType = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.MySql.dll,可前往 nuget 下载"); + break; + case "SqlConnection": + providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.SqlServer.dll,可前往 nuget 下载"); + break; + case "NpgsqlConnection": + providerType = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.PostgreSQL.dll,可前往 nuget 下载"); + break; + case "OracleConnection": + providerType = Type.GetType("FreeSql.Oracle.OracleProvider`1,FreeSql.Provider.Oracle")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Oracle.dll,可前往 nuget 下载"); + break; + case "SQLiteConnection": + providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.Sqlite")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Sqlite.dll,可前往 nuget 下载"); + break; + case "DmConnection": + providerType = Type.GetType("FreeSql.Dameng.DamengProvider`1,FreeSql.Provider.Dameng")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.Dameng.dll,可前往 nuget 下载"); + break; + case "OscarConnection": + providerType = Type.GetType("FreeSql.ShenTong.ShenTongProvider`1,FreeSql.Provider.ShenTong")?.MakeGenericType(connType); + if (providerType == null) throw new Exception("缺少 FreeSql 数据库实现包:FreeSql.Provider.ShenTong.dll,可前往 nuget 下载"); + break; + default: + throw new Exception("未实现"); + } + lock (_dicCurdLock) + { + if (_dicCurd.TryGetValue(connType, out fsql)) return fsql; + lock (_dicCurdLock) + _dicCurd.Add(connType, fsql = Activator.CreateInstance(providerType, new object[] { null, null, null }) as IFreeSql); + } + return fsql; + } + static IFreeSql GetCrud(IDbTransaction dbtran) + { + if (dbtran == null) throw new ArgumentNullException($"{nameof(dbtran)} 不能为 null"); + return GetCrud(dbtran.Connection); + } + + /// + /// 获取 IDbConnection 对应的 IFreeSql 实例 + /// + /// + /// + public static IFreeSql GetIFreeSql(this IDbConnection that) => GetCrud(that); + + #region IDbConnection + /// + /// 插入数据 + /// + /// + /// + public static IInsert Insert(this IDbConnection that) where T1 : class => GetCrud(that).Insert().WithConnection(that as DbConnection); + /// + /// 插入数据,传入实体 + /// + /// + /// + /// + public static IInsert Insert(this IDbConnection that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); + /// + /// 插入数据,传入实体数组 + /// + /// + /// + /// + public static IInsert Insert(this IDbConnection that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); + /// + /// 插入数据,传入实体集合 + /// + /// + /// + /// + public static IInsert Insert(this IDbConnection that, List source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); + /// + /// 插入数据,传入实体集合 + /// + /// + /// + /// + public static IInsert Insert(this IDbConnection that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithConnection(that as DbConnection); + + /// + /// 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + /// 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 + /// 达梦: merge into + /// 人大金仓:on conflict do update + /// 神通:merge into + /// MsAccess:不支持 + /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + /// + /// + /// + public static IInsertOrUpdate InsertOrUpdate(this IDbConnection that) where T1 : class => GetCrud(that).InsertOrUpdate().WithConnection(that as DbConnection); + + /// + /// 修改数据 + /// + /// + /// + 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); + + /// + /// 查询数据 + /// + /// + /// + 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); + + /// + /// 删除数据 + /// + /// + /// + 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); + #endregion + + #region IDbTransaction + /// + /// 插入数据 + /// + /// + /// + public static IInsert Insert(this IDbTransaction that) where T1 : class => GetCrud(that).Insert().WithTransaction(that as DbTransaction); + /// + /// 插入数据,传入实体 + /// + /// + /// + /// + public static IInsert Insert(this IDbTransaction that, T1 source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); + /// + /// 插入数据,传入实体数组 + /// + /// + /// + /// + public static IInsert Insert(this IDbTransaction that, T1[] source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); + /// + /// 插入数据,传入实体集合 + /// + /// + /// + /// + public static IInsert Insert(this IDbTransaction that, List source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); + /// + /// 插入数据,传入实体集合 + /// + /// + /// + /// + public static IInsert Insert(this IDbTransaction that, IEnumerable source) where T1 : class => GetCrud(that).Insert(source).WithTransaction(that as DbTransaction); + + /// + /// 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + /// 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 + /// 达梦: merge into + /// 人大金仓:on conflict do update + /// 神通:merge into + /// MsAccess:不支持 + /// 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + /// + /// + /// + public static IInsertOrUpdate InsertOrUpdate(this IDbTransaction that) where T1 : class => GetCrud(that).InsertOrUpdate().WithTransaction(that as DbTransaction); + + /// + /// 修改数据 + /// + /// + /// + 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); + + /// + /// 查询数据 + /// + /// + /// + 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); + + /// + /// 删除数据 + /// + /// + /// + 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); + #endregion + + #endregion } \ No newline at end of file diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 71cbd656..2bff73de 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -3853,6 +3853,215 @@ 递归层级 + + + 获取 IDbConnection 对应的 IFreeSql 实例 + + + + + + + 插入数据 + + + + + + + 插入数据,传入实体 + + + + + + + + 插入数据,传入实体数组 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + 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 + 达梦: 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} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 插入数据 + + + + + + + 插入数据,传入实体 + + + + + + + + 插入数据,传入实体数组 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + 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 + 达梦: 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} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + 使用 and 拼接两个 lambda 表达式