diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 5e8502b07..931f82fe2 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 4a07cecf8..05f3c979a 100644 --- a/FreeSql/FreeSqlBuilder.cs +++ b/FreeSql/FreeSqlBuilder.cs @@ -22,6 +22,7 @@ public partial class FreeSqlBuilder 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 @@ public FreeSqlBuilder UseNameConvert(NameConvertType convertType) 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 @@ public IFreeSql Build() e.ModifyResult.Name = $"{schema}.{e.EntityType.Name}"; } }); + + ret.Ado.MasterPool.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool; + ret.Ado.SlavePools.ForEach(a => a.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool); } return ret;