Skip to content

Commit

Permalink
Resolved #580: Add TransactionScopeOption to UnitOfWorkAttribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Aug 25, 2015
1 parent af8acf1 commit ede156a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Abp/Domain/Uow/UnitOfWorkAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace Abp.Domain.Uow
[AttributeUsage(AttributeTargets.Method)]
public class UnitOfWorkAttribute : Attribute
{
/// <summary>
/// Scope option.
/// </summary>
public TransactionScopeOption? Scope { get; set; }

/// <summary>
/// Is this UOW transactional?
/// Uses default value if not supplied.
Expand Down Expand Up @@ -104,6 +109,30 @@ public UnitOfWorkAttribute(IsolationLevel isolationLevel, int timeout)
Timeout = TimeSpan.FromMilliseconds(timeout);
}

/// <summary>
/// Creates a new <see cref="UnitOfWorkAttribute"/> object.
/// <see cref="IsTransactional"/> is automatically set to true.
/// </summary>
/// <param name="scope">Transaction scope</param>
public UnitOfWorkAttribute(TransactionScopeOption scope)
{
IsTransactional = true;
Scope = scope;
}

/// <summary>
/// Creates a new <see cref="UnitOfWorkAttribute"/> object.
/// <see cref="IsTransactional"/> is automatically set to true.
/// </summary>
/// <param name="scope">Transaction scope</param>
/// <param name="timeout">Transaction timeout as milliseconds</param>
public UnitOfWorkAttribute(TransactionScopeOption scope, int timeout)
{
IsTransactional = true;
Scope = scope;
Timeout = TimeSpan.FromMilliseconds(timeout);
}

/// <summary>
/// Gets UnitOfWorkAttribute for given method or null if no attribute defined.
/// </summary>
Expand Down Expand Up @@ -131,7 +160,8 @@ internal UnitOfWorkOptions CreateOptions()
{
IsTransactional = IsTransactional,
IsolationLevel = IsolationLevel,
Timeout = Timeout
Timeout = Timeout,
Scope = Scope
};
}
}
Expand Down

0 comments on commit ede156a

Please sign in to comment.