Skip to content

Commit

Permalink
Merge pull request #4363 from abpframework/maliming/UnitOfWorkAttribute
Browse files Browse the repository at this point in the history
Change UOW Timeout property type to int?.
  • Loading branch information
hikalkan authored Jun 16, 2020
2 parents 923c357 + bc76058 commit ae8095d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected virtual void TrySetDatabaseProvider(ModelBuilder modelBuilder)
modelBuilder.SetDatabaseProvider(provider.Value);
}
}

protected virtual EfCoreDatabaseProvider? GetDatabaseProviderOrNull(ModelBuilder modelBuilder)
{
switch (Database.ProviderName)
Expand Down Expand Up @@ -187,7 +187,7 @@ public virtual void Initialize(AbpEfCoreDbContextInitializationContext initializ
Database.IsRelational() &&
!Database.GetCommandTimeout().HasValue)
{
Database.SetCommandTimeout(initializationContext.UnitOfWork.Options.Timeout.Value.TotalSeconds.To<int>());
Database.SetCommandTimeout(TimeSpan.FromMilliseconds(initializationContext.UnitOfWork.Options.Timeout.Value));
}

ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges;
Expand Down Expand Up @@ -627,4 +627,4 @@ public override Expression Visit(Expression node)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Volo.Abp.Uow
{
//TODO: Implement default options!

/// <summary>
/// Global (default) unit of work options
/// </summary>
Expand All @@ -17,7 +17,7 @@ public class AbpUnitOfWorkDefaultOptions

public IsolationLevel? IsolationLevel { get; set; }

public TimeSpan? Timeout { get; set; }
public int? Timeout { get; set; }

internal AbpUnitOfWorkOptions Normalize(AbpUnitOfWorkOptions options)
{
Expand Down Expand Up @@ -49,4 +49,4 @@ public bool CalculateIsTransactional(bool autoValue)
}
}
}
}
}
11 changes: 7 additions & 4 deletions framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ public class AbpUnitOfWorkOptions : IAbpUnitOfWorkOptions

public IsolationLevel? IsolationLevel { get; set; }

public TimeSpan? Timeout { get; set; }
/// <summary>
/// Milliseconds
/// </summary>
public int? Timeout { get; set; }

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;
IsolationLevel = isolationLevel;
Expand All @@ -36,4 +39,4 @@ public AbpUnitOfWorkOptions Clone()
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public interface IAbpUnitOfWorkOptions

IsolationLevel? IsolationLevel { get; }

TimeSpan? Timeout { get; }
/// <summary>
/// Milliseconds
/// </summary>
int? Timeout { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class UnitOfWorkAttribute : Attribute
/// Timeout of UOW As milliseconds.
/// Uses default value if not supplied.
/// </summary>
public TimeSpan? Timeout { get; set; }
public int? Timeout { get; set; }

/// <summary>
/// If this UOW is transactional, this option indicated the isolation level of the transaction.
Expand All @@ -39,7 +39,7 @@ public class UnitOfWorkAttribute : Attribute

public UnitOfWorkAttribute()
{

}

public UnitOfWorkAttribute(bool isTransactional)
Expand All @@ -53,7 +53,7 @@ public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel)
IsolationLevel = isolationLevel;
}

public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, TimeSpan timeout)
public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, int timeout)
{
IsTransactional = isTransactional;
IsolationLevel = isolationLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public static class UnitOfWorkManagerExtensions
{
[NotNull]
public static IUnitOfWork Begin(
[NotNull] this IUnitOfWorkManager unitOfWorkManager,
[NotNull] this IUnitOfWorkManager unitOfWorkManager,
bool requiresNew = false,
bool isTransactional = false,
IsolationLevel? isolationLevel = null,
TimeSpan? timeout = null)
IsolationLevel? isolationLevel = null,
int? timeout = null)
{
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));

Expand Down Expand Up @@ -40,4 +40,4 @@ public static void TryBeginReserved([NotNull] this IUnitOfWorkManager unitOfWork
unitOfWorkManager.TryBeginReserved(reservationName, new AbpUnitOfWorkOptions());
}
}
}
}

0 comments on commit ae8095d

Please sign in to comment.