Skip to content

Commit

Permalink
- 增加 FreeSqlBuilder.UseExitAutoDisposePool 方法;
Browse files Browse the repository at this point in the history
  • Loading branch information
28810 authored and 28810 committed May 21, 2020
1 parent 903a6ad commit e395add
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions FreeSql/FreeSql.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions FreeSql/FreeSqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DbCommand> _aopCommandExecuting = null;
Expand Down Expand Up @@ -151,6 +152,18 @@ public FreeSqlBuilder UseNameConvert(NameConvertType convertType)
return this;
}

/// <summary>
/// 监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放连接池<para></para>
/// 默认值: true
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public FreeSqlBuilder UseExitAutoDisposePool(bool value)
{
_isExitAutoDisposePool = value;
return this;
}

public IFreeSql Build() => Build<IFreeSql>();
public IFreeSql<TMark> Build<TMark>()
{
Expand Down Expand Up @@ -374,6 +387,9 @@ public IFreeSql<TMark> Build<TMark>()
e.ModifyResult.Name = $"{schema}.{e.EntityType.Name}";
}
});

ret.Ado.MasterPool.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool;
ret.Ado.SlavePools.ForEach(a => a.Policy.IsAutoDisposeWithSystem = _isExitAutoDisposePool);
}

return ret;
Expand Down

0 comments on commit e395add

Please sign in to comment.