Skip to content

Commit

Permalink
Resolved #2558: Add options to IUnitOfWorkManager.Begin().
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jan 6, 2020
1 parent 787dd43 commit db1cd57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
12 changes: 12 additions & 0 deletions framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ public class AbpUnitOfWorkOptions : IAbpUnitOfWorkOptions

public TimeSpan? Timeout { get; set; }

public AbpUnitOfWorkOptions()
{

}

public AbpUnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null, TimeSpan? timeout = null)
{
IsTransactional = isTransactional;
IsolationLevel = isolationLevel;
Timeout = timeout;
}

public AbpUnitOfWorkOptions Clone()
{
return new AbpUnitOfWorkOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
using JetBrains.Annotations;
using System;
using System.Data;
using JetBrains.Annotations;

namespace Volo.Abp.Uow
{
public static class UnitOfWorkManagerExtensions
{
[NotNull]
public static IUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false)
public static IUnitOfWork Begin(
[NotNull] this IUnitOfWorkManager unitOfWorkManager,
bool requiresNew = false,
bool isTransactional = false,
IsolationLevel? isolationLevel = null,
TimeSpan? timeout = null)
{
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));

return unitOfWorkManager.Begin(new AbpUnitOfWorkOptions(), requiresNew);
return unitOfWorkManager.Begin(new AbpUnitOfWorkOptions
{
IsTransactional = isTransactional,
IsolationLevel = isolationLevel,
Timeout = timeout
}, requiresNew);
}

public static void BeginReserved([NotNull] this IUnitOfWorkManager unitOfWorkManager, [NotNull] string reservationName)
Expand Down

0 comments on commit db1cd57

Please sign in to comment.