Browse Source

Resolved #2558: Add options to IUnitOfWorkManager.Begin().

pull/2566/head
Halil İbrahim Kalkan 6 years ago
parent
commit
db1cd57787
  1. 12
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs
  2. 18
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs

12
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs

@ -14,6 +14,18 @@ namespace Volo.Abp.Uow
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

18
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs

@ -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)

Loading…
Cancel
Save