diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 5e8502b0..931f82fe 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -755,6 +755,14 @@ + + + 监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放连接池 + 默认值: true + + + + 转小写同步结构 diff --git a/FreeSql/FreeSqlBuilder.cs b/FreeSql/FreeSqlBuilder.cs index 4a07cecf..05f3c979 100644 --- a/FreeSql/FreeSqlBuilder.cs +++ b/FreeSql/FreeSqlBuilder.cs @@ -22,6 +22,7 @@ namespace FreeSql bool _isNoneCommandParameter = false; bool _isGenerateCommandParameterWithLambda = false; bool _isLazyLoading = false; + bool _isExitAutoDisposePool = true; StringConvertType _entityPropertyConvertType = StringConvertType.None; NameConvertType _nameConvertType = NameConvertType.None; Action _aopCommandExecuting = null; @@ -151,6 +152,18 @@ namespace FreeSql return this; } + /// + /// 监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放连接池 + /// 默认值: true + /// + /// + /// + public FreeSqlBuilder UseExitAutoDisposePool(bool value) + { + _isExitAutoDisposePool = value; + return this; + } + public IFreeSql Build() => Build(); public IFreeSql Build() { @@ -374,6 +387,9 @@ namespace FreeSql e.ModifyResult.Name = $"{schema}.{e.EntityType.Name}"; } }); + + ret.Ado.MasterPool.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool; + ret.Ado.SlavePools.ForEach(a => a.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool); } return ret;