- 修正 UnitOfWorkManager Requierd 命名为 Required;

This commit is contained in:
28810 2020-08-17 07:02:32 +08:00
parent d6853e93fe
commit 4acbc712d6
2 changed files with 13 additions and 5 deletions

View File

@ -14,7 +14,7 @@ namespace FreeSql
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class TransactionalAttribute : DynamicProxyAttribute, IActionFilter public class TransactionalAttribute : DynamicProxyAttribute, IActionFilter
{ {
public Propagation Propagation { get; set; } = Propagation.Requierd; public Propagation Propagation { get; set; } = Propagation.Required;
public IsolationLevel IsolationLevel { get => _IsolationLevelPriv.Value; set => _IsolationLevelPriv = value; } public IsolationLevel IsolationLevel { get => _IsolationLevelPriv.Value; set => _IsolationLevelPriv = value; }
IsolationLevel? _IsolationLevelPriv; IsolationLevel? _IsolationLevelPriv;

View File

@ -85,11 +85,12 @@ namespace FreeSql
/// <param name="propagation">事务传播方式</param> /// <param name="propagation">事务传播方式</param>
/// <param name="isolationLevel">事务隔离级别</param> /// <param name="isolationLevel">事务隔离级别</param>
/// <returns></returns> /// <returns></returns>
public IUnitOfWork Begin(Propagation propagation = Propagation.Requierd, IsolationLevel? isolationLevel = null) public IUnitOfWork Begin(Propagation propagation = Propagation.Required, IsolationLevel? isolationLevel = null)
{ {
if (propagation == Propagation.Requierd) propagation = Propagation.Required;
switch (propagation) switch (propagation)
{ {
case Propagation.Requierd: return FindedUowCreateVirtual() ?? CreateUow(isolationLevel); case Propagation.Required: return FindedUowCreateVirtual() ?? CreateUow(isolationLevel);
case Propagation.Supports: return FindedUowCreateVirtual() ?? CreateUowNothing(_allUows.LastOrDefault()?.IsNotSupported ?? false); case Propagation.Supports: return FindedUowCreateVirtual() ?? CreateUowNothing(_allUows.LastOrDefault()?.IsNotSupported ?? false);
case Propagation.Mandatory: return FindedUowCreateVirtual() ?? throw new Exception("Propagation_Mandatory: 使用当前事务,如果没有当前事务,就抛出异常"); case Propagation.Mandatory: return FindedUowCreateVirtual() ?? throw new Exception("Propagation_Mandatory: 使用当前事务,如果没有当前事务,就抛出异常");
case Propagation.NotSupported: return CreateUowNothing(true); case Propagation.NotSupported: return CreateUowNothing(true);
@ -252,7 +253,7 @@ namespace FreeSql
/// <summary> /// <summary>
/// 如果当前没有事务,就新建一个事务,如果已存在一个事务中,加入到这个事务中,默认的选择。 /// 如果当前没有事务,就新建一个事务,如果已存在一个事务中,加入到这个事务中,默认的选择。
/// </summary> /// </summary>
Requierd, Required,
/// <summary> /// <summary>
/// 支持当前事务,如果没有当前事务,就以非事务方法执行。 /// 支持当前事务,如果没有当前事务,就以非事务方法执行。
/// </summary> /// </summary>
@ -272,6 +273,13 @@ namespace FreeSql
/// <summary> /// <summary>
/// 以嵌套事务方式执行。 /// 以嵌套事务方式执行。
/// </summary> /// </summary>
Nested Nested,
/// <summary>
/// 错误的命名,请使用 Required在 2.0.0 删除
/// </summary>
[Obsolete("错误的命名,请使用 Required在 2.0.0 删除")]
Requierd = 404
} }
} }