- 优化 UnitOfWork 与 ForUpdate 事务开启逻辑;

This commit is contained in:
2881099
2022-12-08 15:49:18 +08:00
parent 09864eaa9f
commit 80cfa45f51
4 changed files with 17 additions and 4 deletions

View File

@ -70,7 +70,10 @@ namespace FreeSql
{
var db = _resolveDbContext?.Invoke();
db?.FlushCommand();
var select = _originalFsql.Select<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction(false));
var uow = _resolveUnitOfWork?.Invoke();
var uowIsolationLevel = uow?.IsolationLevel ?? IsolationLevel.Unspecified;
var select = _originalFsql.Select<T1>().WithTransaction(uow?.GetOrBeginTransaction(uowIsolationLevel != IsolationLevel.Unspecified));
(select as Select0Provider)._resolveHookTransaction = () => uow?.GetOrBeginTransaction();
if (db?.Options.EnableGlobalFilter == false) select.DisableGlobalFilter();
return select;
}