Browse Source

Change UOW Timeout property type to int?.

Resolve #4355
pull/4363/head
maliming 6 years ago
parent
commit
1ce6f8cdcf
  1. 6
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
  2. 6
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs
  3. 8
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs
  4. 4
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs
  5. 6
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs
  6. 8
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs

6
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs

@ -118,7 +118,7 @@ namespace Volo.Abp.EntityFrameworkCore
modelBuilder.SetDatabaseProvider(provider.Value); modelBuilder.SetDatabaseProvider(provider.Value);
} }
} }
protected virtual EfCoreDatabaseProvider? GetDatabaseProviderOrNull(ModelBuilder modelBuilder) protected virtual EfCoreDatabaseProvider? GetDatabaseProviderOrNull(ModelBuilder modelBuilder)
{ {
switch (Database.ProviderName) switch (Database.ProviderName)
@ -187,7 +187,7 @@ namespace Volo.Abp.EntityFrameworkCore
Database.IsRelational() && Database.IsRelational() &&
!Database.GetCommandTimeout().HasValue) !Database.GetCommandTimeout().HasValue)
{ {
Database.SetCommandTimeout(initializationContext.UnitOfWork.Options.Timeout.Value.TotalSeconds.To<int>()); Database.SetCommandTimeout(initializationContext.UnitOfWork.Options.Timeout.Value);
} }
ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges; ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges;
@ -627,4 +627,4 @@ namespace Volo.Abp.EntityFrameworkCore
} }
} }
} }
} }

6
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs

@ -4,7 +4,7 @@ using System.Data;
namespace Volo.Abp.Uow namespace Volo.Abp.Uow
{ {
//TODO: Implement default options! //TODO: Implement default options!
/// <summary> /// <summary>
/// Global (default) unit of work options /// Global (default) unit of work options
/// </summary> /// </summary>
@ -17,7 +17,7 @@ namespace Volo.Abp.Uow
public IsolationLevel? IsolationLevel { get; set; } public IsolationLevel? IsolationLevel { get; set; }
public TimeSpan? Timeout { get; set; } public int? Timeout { get; set; }
internal AbpUnitOfWorkOptions Normalize(AbpUnitOfWorkOptions options) internal AbpUnitOfWorkOptions Normalize(AbpUnitOfWorkOptions options)
{ {
@ -49,4 +49,4 @@ namespace Volo.Abp.Uow
} }
} }
} }
} }

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

@ -12,14 +12,14 @@ namespace Volo.Abp.Uow
public IsolationLevel? IsolationLevel { get; set; } public IsolationLevel? IsolationLevel { get; set; }
public TimeSpan? Timeout { get; set; } public int? Timeout { get; set; }
public AbpUnitOfWorkOptions() public AbpUnitOfWorkOptions()
{ {
} }
public AbpUnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null, TimeSpan? timeout = null) public AbpUnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null, int? timeout = null)
{ {
IsTransactional = isTransactional; IsTransactional = isTransactional;
IsolationLevel = isolationLevel; IsolationLevel = isolationLevel;
@ -36,4 +36,4 @@ namespace Volo.Abp.Uow
}; };
} }
} }
} }

4
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs

@ -9,6 +9,6 @@ namespace Volo.Abp.Uow
IsolationLevel? IsolationLevel { get; } IsolationLevel? IsolationLevel { get; }
TimeSpan? Timeout { get; } int? Timeout { get; }
} }
} }

6
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs

@ -22,7 +22,7 @@ namespace Volo.Abp.Uow
/// Timeout of UOW As milliseconds. /// Timeout of UOW As milliseconds.
/// Uses default value if not supplied. /// Uses default value if not supplied.
/// </summary> /// </summary>
public TimeSpan? Timeout { get; set; } public int? Timeout { get; set; }
/// <summary> /// <summary>
/// If this UOW is transactional, this option indicated the isolation level of the transaction. /// If this UOW is transactional, this option indicated the isolation level of the transaction.
@ -39,7 +39,7 @@ namespace Volo.Abp.Uow
public UnitOfWorkAttribute() public UnitOfWorkAttribute()
{ {
} }
public UnitOfWorkAttribute(bool isTransactional) public UnitOfWorkAttribute(bool isTransactional)
@ -53,7 +53,7 @@ namespace Volo.Abp.Uow
IsolationLevel = isolationLevel; IsolationLevel = isolationLevel;
} }
public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, TimeSpan timeout) public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, int timeout)
{ {
IsTransactional = isTransactional; IsTransactional = isTransactional;
IsolationLevel = isolationLevel; IsolationLevel = isolationLevel;

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

@ -8,11 +8,11 @@ namespace Volo.Abp.Uow
{ {
[NotNull] [NotNull]
public static IUnitOfWork Begin( public static IUnitOfWork Begin(
[NotNull] this IUnitOfWorkManager unitOfWorkManager, [NotNull] this IUnitOfWorkManager unitOfWorkManager,
bool requiresNew = false, bool requiresNew = false,
bool isTransactional = false, bool isTransactional = false,
IsolationLevel? isolationLevel = null, IsolationLevel? isolationLevel = null,
TimeSpan? timeout = null) int? timeout = null)
{ {
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager)); Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));
@ -40,4 +40,4 @@ namespace Volo.Abp.Uow
unitOfWorkManager.TryBeginReserved(reservationName, new AbpUnitOfWorkOptions()); unitOfWorkManager.TryBeginReserved(reservationName, new AbpUnitOfWorkOptions());
} }
} }
} }

Loading…
Cancel
Save