mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 IUnitOfWork Orm 属性直接访问 IFreeSql CRUD 事务与工作单元一致;
This commit is contained in:
@ -10,6 +10,7 @@ namespace FreeSql
|
||||
/// </summary>
|
||||
public interface IUnitOfWork : IDisposable
|
||||
{
|
||||
IFreeSql Orm { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 开启事务,或者返回已开启的事务
|
||||
@ -27,7 +28,7 @@ namespace FreeSql
|
||||
/// <summary>
|
||||
/// 是否启用工作单元
|
||||
/// </summary>
|
||||
[Obsolete("即将删除(保留到2020-08-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
[Obsolete("即将删除(保留到2020-12-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
bool Enable { get; }
|
||||
|
||||
/// <summary>
|
||||
@ -36,13 +37,13 @@ namespace FreeSql
|
||||
/// <para></para>
|
||||
/// 若已开启事务(已有Insert/Update/Delete操作),调用此方法将发生异常,建议在执行逻辑前调用
|
||||
/// </summary>
|
||||
[Obsolete("即将删除(保留到2020-08-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
[Obsolete("即将删除(保留到2020-12-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// 开启工作单元
|
||||
/// </summary>
|
||||
[Obsolete("即将删除(保留到2020-08-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
[Obsolete("即将删除(保留到2020-12-01),请改用 UnitOfWorkManager 的方式管理事务 https://github.com/dotnetcore/FreeSql/issues/289")]
|
||||
void Open();
|
||||
|
||||
/// <summary>
|
||||
|
@ -64,6 +64,9 @@ namespace FreeSql
|
||||
Enable = true;
|
||||
}
|
||||
|
||||
DbContextScopedFreeSql _ormScoped;
|
||||
public IFreeSql Orm => _ormScoped ?? (_ormScoped = DbContextScopedFreeSql.Create(_fsql, null, () => this));
|
||||
|
||||
public IsolationLevel? IsolationLevel { get; set; }
|
||||
|
||||
public DbTransaction GetOrBeginTransaction(bool isCreate = true)
|
||||
|
@ -184,6 +184,7 @@ namespace FreeSql
|
||||
IUnitOfWork _baseUow;
|
||||
internal Action OnDispose;
|
||||
public UnitOfWorkOrginal(IUnitOfWork baseUow) => _baseUow = baseUow;
|
||||
public IFreeSql Orm => _baseUow.Orm;
|
||||
public IsolationLevel? IsolationLevel { get => _baseUow.IsolationLevel; set => _baseUow.IsolationLevel = value; }
|
||||
public DbContext.EntityChangeReport EntityChangeReport => _baseUow.EntityChangeReport;
|
||||
|
||||
@ -205,6 +206,7 @@ namespace FreeSql
|
||||
IUnitOfWork _baseUow;
|
||||
internal Action OnDispose;
|
||||
public UnitOfWorkVirtual(IUnitOfWork baseUow) => _baseUow = baseUow;
|
||||
public IFreeSql Orm => _baseUow.Orm;
|
||||
public IsolationLevel? IsolationLevel { get => _baseUow.IsolationLevel; set { } }
|
||||
public DbContext.EntityChangeReport EntityChangeReport => _baseUow.EntityChangeReport;
|
||||
|
||||
@ -222,6 +224,7 @@ namespace FreeSql
|
||||
internal IFreeSql _fsql;
|
||||
internal Action OnDispose;
|
||||
public UnitOfWorkNothing(IFreeSql fsql) => _fsql = fsql;
|
||||
public IFreeSql Orm => _fsql;
|
||||
public IsolationLevel? IsolationLevel { get; set; }
|
||||
public DbContext.EntityChangeReport EntityChangeReport { get; } = new DbContext.EntityChangeReport();
|
||||
|
||||
|
Reference in New Issue
Block a user