mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 优化 UnitOfWork 与 ForUpdate 事务开启逻辑;
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using System.Data;
|
||||
|
||||
namespace FreeSql
|
||||
{
|
||||
@ -34,7 +35,9 @@ namespace FreeSql
|
||||
protected virtual ISelect<TEntity> OrmSelect(object dywhere)
|
||||
{
|
||||
DbContextFlushCommand(); //查询前先提交,否则会出脏读
|
||||
var select = _db.OrmOriginal.Select<TEntity>().AsType(_entityType).WithTransaction(_uow?.GetOrBeginTransaction(false)).TrackToList(TrackToList).WhereDynamic(dywhere);
|
||||
var uowIsolationLevel = _uow?.IsolationLevel ?? IsolationLevel.Unspecified;
|
||||
var select = _db.OrmOriginal.Select<TEntity>().AsType(_entityType).WithTransaction(_uow?.GetOrBeginTransaction(uowIsolationLevel != IsolationLevel.Unspecified)).TrackToList(TrackToList).WhereDynamic(dywhere);
|
||||
(select as Select0Provider)._resolveHookTransaction = () => _uow?.GetOrBeginTransaction();
|
||||
if (_db.Options.EnableGlobalFilter == false) select.DisableGlobalFilter();
|
||||
return select;
|
||||
}
|
||||
|
Reference in New Issue
Block a user