diff --git a/Examples/repository_01/Controllers/SongController.cs b/Examples/repository_01/Controllers/SongController.cs index 36660b75..46a48d7b 100644 --- a/Examples/repository_01/Controllers/SongController.cs +++ b/Examples/repository_01/Controllers/SongController.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNetCore.Mvc; -using repository_01.Repositorys; +using FreeSql; +using Microsoft.AspNetCore.Mvc; using restful.Entitys; using System; using System.Collections.Generic; @@ -8,14 +8,27 @@ using System.Threading.Tasks; namespace restful.Controllers { - [Route("restapi/[controller]")] public class SongsController : Controller { - SongRepository _songRepository; + BaseRepository _songRepository; - public SongsController(IFreeSql fsql) { - _songRepository = new SongRepository(fsql); + public class xxxx { + public int Id { get; set; } + } + + public SongsController(IFreeSql fsql, + GuidRepository repos1, + GuidRepository repos2, + + DefaultRepository repos11, + DefaultRepository repos21, + + BaseRepository repos3, BaseRepository repos4, + IBasicRepository repos31, IBasicRepository repos41, + IReadOnlyRepository repos311, IReadOnlyRepository repos411 + ) { + _songRepository = repos4; //test code var curd1 = fsql.GetRepository(); diff --git a/Examples/repository_01/Properties/launchSettings.json b/Examples/repository_01/Properties/launchSettings.json index c671858d..ad8494da 100644 --- a/Examples/repository_01/Properties/launchSettings.json +++ b/Examples/repository_01/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:54379/", + "applicationUrl": "http://localhost:64150/", "sslPort": 0 } }, @@ -21,7 +21,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:54383/" + "applicationUrl": "http://localhost:64154/" } } } \ No newline at end of file diff --git a/Examples/repository_01/Repositorys/SongRepository.cs b/Examples/repository_01/Repositorys/SongRepository.cs deleted file mode 100644 index 764b5af9..00000000 --- a/Examples/repository_01/Repositorys/SongRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FreeSql; -using restful.Entitys; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace repository_01.Repositorys { - public class SongRepository : DefaultRepository { - public SongRepository(IFreeSql fsql) : base(fsql, null) { - } - } -} diff --git a/Examples/repository_01/Startup.cs b/Examples/repository_01/Startup.cs index f827dfe5..e981f6d3 100644 --- a/Examples/repository_01/Startup.cs +++ b/Examples/repository_01/Startup.cs @@ -1,9 +1,11 @@ -using FreeSql; +using Autofac; +using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using restful.Entitys; using Swashbuckle.AspNetCore.Swagger; using System; using System.Text; @@ -23,8 +25,10 @@ namespace repository_01 { public IConfiguration Configuration { get; } public IFreeSql Fsql { get; } - public void ConfigureServices(IServiceCollection services) { + public IServiceProvider ConfigureServices(IServiceCollection services) { + services.AddSingleton(Fsql); + //services.AddTransient(s => s.) services.AddMvc(); services.AddSwaggerGen(options => { @@ -34,6 +38,16 @@ namespace repository_01 { }); //options.IncludeXmlComments(xmlPath); }); + + var builder = new ContainerBuilder(); + + builder.RegisterFreeRepository(a => a.Id == 1); + builder.RegisterFreeGuidRepository(a => a.Id == 1, oldname => $"{oldname}_{DateTime.Now.Year}"); + + builder.Populate(services); + var container = builder.Build(); + + return new AutofacServiceProvider(container); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { diff --git a/Examples/repository_01/repository_01.csproj b/Examples/repository_01/repository_01.csproj index bb3ba347..3905e922 100644 --- a/Examples/repository_01/repository_01.csproj +++ b/Examples/repository_01/repository_01.csproj @@ -16,8 +16,4 @@ - - - - diff --git a/FreeSql.Repository/BaseRepository.cs b/FreeSql.Repository/BaseRepository.cs index d834ce4b..d4f8e919 100644 --- a/FreeSql.Repository/BaseRepository.cs +++ b/FreeSql.Repository/BaseRepository.cs @@ -9,35 +9,54 @@ namespace FreeSql { where TEntity : class { protected IFreeSql _fsql; - protected Expression> _filter; - protected Func _filterCompile; - protected Func _asTable; - protected Func _asTableSelect => _asTable == null ? null : new Func((a, b) => a == _entityType ? _asTable(b) : null); - protected Type _entityType = typeof(TEntity); + + Expression> _filterVal; + protected Expression> Filter { + get => _filterVal; + set { + _filterVal = value; + FilterCompile = value?.Compile(); + } + } + internal Expression> FilterInternal => Filter; + protected Func FilterCompile { get; private set; } + internal Func FilterCompileInternal => FilterCompile; + + Func _asTableVal; + protected Func AsTable { + get => _asTableVal; + set { + _asTableVal = value; + AsTableSelect = value == null ? null : new Func((a, b) => a == EntityType ? value(b) : null); + } + } + protected Func AsTableSelect { get; private set; } + internal Func AsTableSelectInternal => AsTableSelect; + + protected Type EntityType { get; } = typeof(TEntity); protected BaseRepository(IFreeSql fsql, Expression> filter, Func asTable = null) : base() { _fsql = fsql ?? throw new NullReferenceException("fsql 参数不可为空"); - _filter = filter; - _filterCompile = filter?.Compile(); - _asTable = asTable; + Filter = filter; + AsTable = asTable; } - public ISelect Select => _fsql.Select().Where(_filter).AsTable(_asTableSelect); + public ISelect Select => _fsql.Select().Where(Filter).AsTable(AsTableSelect); - public IUpdate UpdateDiy => _fsql.Update().Where(_filter).AsTable(_asTable); + public IUpdate UpdateDiy => _fsql.Update().Where(Filter).AsTable(AsTable); - public int Delete(Expression> predicate) => _fsql.Delete().Where(_filter).Where(predicate).AsTable(_asTable).ExecuteAffrows(); + public int Delete(Expression> predicate) => _fsql.Delete().Where(Filter).Where(predicate).AsTable(AsTable).ExecuteAffrows(); public int Delete(TEntity entity) { ValidatorEntityAndThrow(entity); - return _fsql.Delete(entity).Where(_filter).AsTable(_asTable).ExecuteAffrows(); + return _fsql.Delete(entity).Where(Filter).AsTable(AsTable).ExecuteAffrows(); } - public Task DeleteAsync(Expression> predicate) => _fsql.Delete().Where(_filter).Where(predicate).AsTable(_asTable).ExecuteAffrowsAsync(); + public Task DeleteAsync(Expression> predicate) => _fsql.Delete().Where(Filter).Where(predicate).AsTable(AsTable).ExecuteAffrowsAsync(); public Task DeleteAsync(TEntity entity) { ValidatorEntityAndThrow(entity); - return _fsql.Delete(entity).Where(_filter).AsTable(_asTable).ExecuteAffrowsAsync(); + return _fsql.Delete(entity).Where(Filter).AsTable(AsTable).ExecuteAffrowsAsync(); } public virtual TEntity Insert(TEntity entity) { @@ -45,7 +64,7 @@ namespace FreeSql { switch (_fsql.Ado.DataType) { case DataType.SqlServer: case DataType.PostgreSQL: - return _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteInserted().FirstOrDefault(); + return _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteInserted().FirstOrDefault(); case DataType.MySql: case DataType.Oracle: case DataType.Sqlite: @@ -59,7 +78,7 @@ namespace FreeSql { switch (_fsql.Ado.DataType) { case DataType.SqlServer: case DataType.PostgreSQL: - return _fsql.Insert().AppendData(entitys).AsTable(_asTable).ExecuteInserted(); + return _fsql.Insert().AppendData(entitys).AsTable(AsTable).ExecuteInserted(); case DataType.MySql: case DataType.Oracle: case DataType.Sqlite: @@ -73,7 +92,7 @@ namespace FreeSql { switch (_fsql.Ado.DataType) { case DataType.SqlServer: case DataType.PostgreSQL: - return (await _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteInsertedAsync()).FirstOrDefault(); + return (await _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteInsertedAsync()).FirstOrDefault(); case DataType.MySql: case DataType.Oracle: case DataType.Sqlite: @@ -87,7 +106,7 @@ namespace FreeSql { switch (_fsql.Ado.DataType) { case DataType.SqlServer: case DataType.PostgreSQL: - return _fsql.Insert().AppendData(entitys).AsTable(_asTable).ExecuteInsertedAsync(); + return _fsql.Insert().AppendData(entitys).AsTable(AsTable).ExecuteInsertedAsync(); case DataType.MySql: case DataType.Oracle: case DataType.Sqlite: @@ -98,18 +117,18 @@ namespace FreeSql { public int Update(TEntity entity) { ValidatorEntityAndThrow(entity); - return _fsql.Update().SetSource(entity).Where(_filter).AsTable(_asTable).ExecuteAffrows(); + return _fsql.Update().SetSource(entity).Where(Filter).AsTable(AsTable).ExecuteAffrows(); } public Task UpdateAsync(TEntity entity) { ValidatorEntityAndThrow(entity); - return _fsql.Update().SetSource(entity).Where(_filter).AsTable(_asTable).ExecuteAffrowsAsync(); + return _fsql.Update().SetSource(entity).Where(Filter).AsTable(AsTable).ExecuteAffrowsAsync(); } protected void ValidatorEntityAndThrow(TEntity entity) => ValidatorEntityAndThrow(new[] { entity }); protected virtual void ValidatorEntityAndThrow(IEnumerable entitys) { foreach (var entity in entitys) { - if (_filterCompile?.Invoke(entity) == false) throw new Exception($"FreeSql.Repository Insert 失败,因为设置了 {_filter},插入的数据不符合"); + if (FilterCompile?.Invoke(entity) == false) throw new Exception($"FreeSql.Repository Insert 失败,因为设置了 {Filter},插入的数据不符合"); } } } @@ -120,13 +139,13 @@ namespace FreeSql { public BaseRepository(IFreeSql fsql, Expression> filter, Func asTable = null) : base(fsql, filter, asTable) { } - public int Delete(TKey id) => _fsql.Delete(id).Where(_filter).AsTable(_asTable).ExecuteAffrows(); + public int Delete(TKey id) => _fsql.Delete(id).Where(Filter).AsTable(AsTable).ExecuteAffrows(); - public Task DeleteAsync(TKey id) => _fsql.Delete(id).Where(_filter).AsTable(_asTable).ExecuteAffrowsAsync(); + public Task DeleteAsync(TKey id) => _fsql.Delete(id).Where(Filter).AsTable(AsTable).ExecuteAffrowsAsync(); - public TEntity Find(TKey id) => _fsql.Select(id).Where(_filter).AsTable(_asTableSelect).ToOne(); + public TEntity Find(TKey id) => _fsql.Select(id).Where(Filter).AsTable(AsTableSelect).ToOne(); - public Task FindAsync(TKey id) => _fsql.Select(id).Where(_filter).AsTable(_asTableSelect).ToOneAsync(); + public Task FindAsync(TKey id) => _fsql.Select(id).Where(Filter).AsTable(AsTableSelect).ToOneAsync(); public TEntity Get(TKey id) => Find(id); diff --git a/FreeSql.Repository/DefaultRepository.cs b/FreeSql.Repository/DefaultRepository.cs index 50dc1a67..3079b308 100644 --- a/FreeSql.Repository/DefaultRepository.cs +++ b/FreeSql.Repository/DefaultRepository.cs @@ -9,6 +9,10 @@ namespace FreeSql { BaseRepository where TEntity : class { + public DefaultRepository(IFreeSql fsql) : base(fsql, null, null) { + + } + public DefaultRepository(IFreeSql fsql, Expression> filter) : base(fsql, filter, null) { } } diff --git a/FreeSql.Repository/DependencyInjection.cs b/FreeSql.Repository/DependencyInjection.cs new file mode 100644 index 00000000..84ca2729 --- /dev/null +++ b/FreeSql.Repository/DependencyInjection.cs @@ -0,0 +1,82 @@ +using Autofac; +using FreeSql; +using System; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Linq.Expressions; +using System.Reflection; + +public static class FreeSqlRepositoryAutofacDependencyInjection { + + public static void RegisterFreeGuidRepository(this ContainerBuilder builder, Expression> filter, Func asTable) => + builder.RegisterRepository(filter, asTable, 1); + public static void RegisterFreeRepository(this ContainerBuilder builder, Expression> filter) => + builder.RegisterRepository(filter, null, 2); + + static void RegisterRepository(this ContainerBuilder builder, Expression> filter, Func asTable, int regType) { + + Func reposFunc = type => { + var entityType = type.GenericTypeArguments[0]; + var filterParameter1 = Expression.Parameter(entityType, filter.Parameters[0].Name); + var convertFilter = Expression.Lambda( + typeof(Func<,>).MakeGenericType(entityType, typeof(bool)), + new ReplaceVisitor().Modify(filter.Body, filterParameter1), + filterParameter1 + ); + var repos = Expression.Parameter(type); + var blocks = new List(); + if (filter != null) blocks.Add(Expression.Call(repos, type.GetMethod("set_Filter", BindingFlags.Instance | BindingFlags.NonPublic), Expression.Constant(convertFilter))); + if (asTable != null) blocks.Add(Expression.Call(repos, type.GetMethod("set_AsTable", BindingFlags.Instance | BindingFlags.NonPublic), Expression.Constant(asTable))); + return Expression.Lambda( + //Expression.New( + // typeof(GuidRepository<>).MakeGenericType(type.GenericTypeArguments).GetConstructors()[1], + // Expression.Constant(a.Context.Resolve()), + // Expression.Constant(convertFilter), + // Expression.Constant(asTable) + //) + Expression.Block(blocks), + repos + ); + }; + + if (regType == 1) + builder.RegisterGeneric(typeof(GuidRepository<>)).As( + typeof(GuidRepository<>), + typeof(BaseRepository<>), typeof(BaseRepository<,>), + typeof(IBasicRepository<>), typeof(IBasicRepository<,>), + typeof(IReadOnlyRepository<>), typeof(IReadOnlyRepository<,>) + ).OnActivating(a => { + if (filter != null) + _dicAddGuidRepositoryFunc.GetOrAdd(a.Instance.GetType(), t => reposFunc(t).Compile()).DynamicInvoke(a.Instance); + }).InstancePerDependency(); + + + if (regType == 2) + builder.RegisterGeneric(typeof(DefaultRepository<,>)).As( + typeof(DefaultRepository<,>), + typeof(BaseRepository<,>), + typeof(IBasicRepository<,>), + typeof(IReadOnlyRepository<,>) + ).OnActivating(a => { + if (filter != null) + _dicAddGuidRepositoryFunc.GetOrAdd(a.Instance.GetType(), t => reposFunc(t).Compile()).DynamicInvoke(a.Instance); + }).InstancePerDependency(); + } + + static ConcurrentDictionary _dicAddGuidRepositoryFunc = new ConcurrentDictionary(); + + class ReplaceVisitor : ExpressionVisitor { + private ParameterExpression parameter; + + public Expression Modify(Expression expression, ParameterExpression parameter) { + this.parameter = parameter; + return Visit(expression); + } + + protected override Expression VisitMember(MemberExpression node) { + if (node.Expression?.NodeType == ExpressionType.Parameter) + return Expression.Property(parameter, node.Member.Name); + return base.VisitMember(node); + } + } +} diff --git a/FreeSql.Repository/FreeSql.Repository.csproj b/FreeSql.Repository/FreeSql.Repository.csproj index 8332cd22..ddb7266b 100644 --- a/FreeSql.Repository/FreeSql.Repository.csproj +++ b/FreeSql.Repository/FreeSql.Repository.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 0.1.12 + 0.1.13 YeXiangQin FreeSql 通用仓库层实现,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite,读写分离、分表分库。 https://github.com/2881099/FreeSql @@ -10,6 +10,10 @@ true + + + + diff --git a/FreeSql.Repository/GuidRepository.cs b/FreeSql.Repository/GuidRepository.cs index ece14136..1ead9a92 100644 --- a/FreeSql.Repository/GuidRepository.cs +++ b/FreeSql.Repository/GuidRepository.cs @@ -10,26 +10,33 @@ namespace FreeSql { BaseRepository where TEntity : class { + public GuidRepository(IFreeSql fsql) : this(fsql, null, null) { + + } public GuidRepository(IFreeSql fsql, Expression> filter, Func asTable) : base(fsql, filter, asTable) { } public override List Insert(IEnumerable entity) { - _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteAffrows(); + base.ValidatorEntityAndThrow(entity); + _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteAffrows(); return entity.ToList(); } async public override Task> InsertAsync(IEnumerable entity) { - await _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteAffrowsAsync(); + base.ValidatorEntityAndThrow(entity); + await _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteAffrowsAsync(); return entity.ToList(); } public override TEntity Insert(TEntity entity) { - _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteAffrows(); + base.ValidatorEntityAndThrow(entity); + _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteAffrows(); return entity; } async public override Task InsertAsync(TEntity entity) { - await _fsql.Insert().AppendData(entity).AsTable(_asTable).ExecuteAffrowsAsync(); + base.ValidatorEntityAndThrow(entity); + await _fsql.Insert().AppendData(entity).AsTable(AsTable).ExecuteAffrowsAsync(); return entity; } } diff --git a/FreeSql.Repository/IFreeSqlExtenssions.cs b/FreeSql.Repository/IFreeSqlExtenssions.cs index f6334996..7c9e0346 100644 --- a/FreeSql.Repository/IFreeSqlExtenssions.cs +++ b/FreeSql.Repository/IFreeSqlExtenssions.cs @@ -42,4 +42,16 @@ public static class IFreeSqlExtenssions { .GetOrAdd(typeof(TEntity), key1 => new GuidRepository(that, null, null)) as GuidRepository; } static ConcurrentDictionary dicGetGuidRepository = new ConcurrentDictionary(); + + /// + /// 合并两个仓储的设置,以便查询 + /// + /// + /// + /// + /// + /// + public static ISelect FromRepository(this ISelect that, BaseRepository repos) where TEntity : class where T2 : class { + return that.AsTable(repos.AsTableSelectInternal).Where(repos.FilterInternal); + } } \ No newline at end of file diff --git a/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs b/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs index 43df2feb..a5bd202d 100644 --- a/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs +++ b/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs @@ -548,6 +548,24 @@ namespace FreeSql.Tests.Sqlite { [Fact] public void AsTable() { + + var tenantId = 1; + var reposTopic = g.sqlite.GetGuidRepository(null, oldname => $"{oldname}_{tenantId}"); + var reposType = g.sqlite.GetGuidRepository(null, oldname => $"{oldname}_{tenantId}"); + + //reposTopic.Delete(Guid.Empty); + //reposTopic.Find(Guid.Empty); + //reposTopic.Update(new Topic { TestTypeInfoGuid = 1 }); + var sql11 = reposTopic.Select + + .FromRepository(reposType) + .From((s,b,c) => s) + + .LeftJoin(a => a.TestTypeInfoGuid == a.Type.Guid) + .ToSql(); + + + Func tableRule = (type, oldname) => { if (type == typeof(Topic)) return oldname + "AsTable1"; else if (type == typeof(TestTypeInfo)) return oldname + "AsTable2"; diff --git a/FreeSql/FreeSql.csproj b/FreeSql/FreeSql.csproj index 26eacc22..0218f987 100644 --- a/FreeSql/FreeSql.csproj +++ b/FreeSql/FreeSql.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 0.1.12 + 0.1.13 true YeXiangQin 打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite,读写分离、分表分库。 diff --git a/FreeSql/Interface/Curd/ISelect/ISelect1.cs b/FreeSql/Interface/Curd/ISelect/ISelect1.cs index cac2ef9e..b407b933 100644 --- a/FreeSql/Interface/Curd/ISelect/ISelect1.cs +++ b/FreeSql/Interface/Curd/ISelect/ISelect1.cs @@ -196,6 +196,13 @@ namespace FreeSql { /// 多表条件查询 /// /// + /// lambda表达式 + /// + ISelect Where(Expression> exp) where T2 : class; + /// + /// 多表条件查询 + /// + /// /// /// lambda表达式 /// diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs index 75eb4afe..e7fb0af0 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs @@ -108,6 +108,7 @@ namespace FreeSql.Internal.CommonProvider { public ISelect Where(Expression> exp) => this.InternalWhere(exp?.Body); public ISelect Where(Expression> exp) where T2 : class => this.InternalWhere(exp?.Body); + public ISelect Where(Expression> exp) where T2 : class => this.InternalWhere(exp?.Body); public ISelect Where(Expression> exp) where T2 : class where T3 : class => this.InternalWhere(exp?.Body); diff --git a/FreeSql/MySql/MySqlAdo/MySqlConnectionPool.cs b/FreeSql/MySql/MySqlAdo/MySqlConnectionPool.cs index ac677353..f86267e7 100644 --- a/FreeSql/MySql/MySqlAdo/MySqlConnectionPool.cs +++ b/FreeSql/MySql/MySqlAdo/MySqlConnectionPool.cs @@ -141,7 +141,7 @@ namespace FreeSql.MySql { static DbCommand PingCommand(DbConnection conn) { var cmd = conn.CreateCommand(); - cmd.CommandTimeout = 1; + cmd.CommandTimeout = 5; cmd.CommandText = "select 1"; return cmd; } diff --git a/FreeSql/Oracle/OracleAdo/OracleConnectionPool.cs b/FreeSql/Oracle/OracleAdo/OracleConnectionPool.cs index 067baef2..1ba5e205 100644 --- a/FreeSql/Oracle/OracleAdo/OracleConnectionPool.cs +++ b/FreeSql/Oracle/OracleAdo/OracleConnectionPool.cs @@ -155,7 +155,7 @@ namespace FreeSql.Oracle { static DbCommand PingCommand(DbConnection conn) { var cmd = conn.CreateCommand(); - cmd.CommandTimeout = 1; + cmd.CommandTimeout = 5; cmd.CommandText = "select 1 from dual"; return cmd; } diff --git a/FreeSql/PostgreSQL/PostgreSQLAdo/PostgreSQLConnectionPool.cs b/FreeSql/PostgreSQL/PostgreSQLAdo/PostgreSQLConnectionPool.cs index 1100a6e5..e79c2d91 100644 --- a/FreeSql/PostgreSQL/PostgreSQLAdo/PostgreSQLConnectionPool.cs +++ b/FreeSql/PostgreSQL/PostgreSQLAdo/PostgreSQLConnectionPool.cs @@ -150,7 +150,7 @@ namespace FreeSql.PostgreSQL { static DbCommand PingCommand(DbConnection conn) { var cmd = conn.CreateCommand(); - cmd.CommandTimeout = 1; + cmd.CommandTimeout = 5; cmd.CommandText = "select 1"; return cmd; } diff --git a/FreeSql/SqlServer/SqlServerAdo/SqlServerConnectionPool.cs b/FreeSql/SqlServer/SqlServerAdo/SqlServerConnectionPool.cs index 29119c03..81653ee4 100644 --- a/FreeSql/SqlServer/SqlServerAdo/SqlServerConnectionPool.cs +++ b/FreeSql/SqlServer/SqlServerAdo/SqlServerConnectionPool.cs @@ -145,7 +145,7 @@ namespace FreeSql.SqlServer { static DbCommand PingCommand(DbConnection conn) { var cmd = conn.CreateCommand(); - cmd.CommandTimeout = 1; + cmd.CommandTimeout = 5; cmd.CommandText = "select 1"; return cmd; } diff --git a/FreeSql/Sqlite/SqliteAdo/SqliteConnectionPool.cs b/FreeSql/Sqlite/SqliteAdo/SqliteConnectionPool.cs index 4dda5649..a50f8743 100644 --- a/FreeSql/Sqlite/SqliteAdo/SqliteConnectionPool.cs +++ b/FreeSql/Sqlite/SqliteAdo/SqliteConnectionPool.cs @@ -151,7 +151,7 @@ namespace FreeSql.Sqlite { static DbCommand PingCommand(DbConnection conn) { var cmd = conn.CreateCommand(); - cmd.CommandTimeout = 1; + cmd.CommandTimeout = 5; cmd.CommandText = "select 1"; return cmd; } diff --git a/readme.md b/readme.md index c17387b6..a8db7c96 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ FreeSql是一个功能强大的NETStandard库,用于对象关系映射程序(O - [x] 支持丰富的表达式函数; - [x] 支持导航属性查询,和延时加载; - [x] 支持同步/异步数据库操作方法,丰富多彩的链式查询方法; -- [x] 支持读写分离、分表分库; +- [x] 支持读写分离、分表分库,租户设计; - [x] 支持多种数据库,MySql/SqlServer/PostgreSQL/Oracle/Sqlite; [《Select查询数据文档》](https://github.com/2881099/FreeSql/wiki/%e6%9f%a5%e8%af%a2) | [《Update更新数据文档》](https://github.com/2881099/FreeSql/wiki/%e4%bf%ae%e6%94%b9) | [《Insert插入数据文档》](https://github.com/2881099/FreeSql/wiki/%e6%b7%bb%e5%8a%a0) | [《Delete删除数据文档》](https://github.com/2881099/FreeSql/wiki/%e5%88%a0%e9%99%a4)