mirror of https://github.com/abpframework/abp.git
13 changed files with 225 additions and 27 deletions
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using System.Threading; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.DependencyInjection |
|||
{ |
|||
internal class DbContextOptionsFactoryContext |
|||
{ |
|||
public static DbContextOptionsFactoryContext Current => _current.Value; |
|||
private static readonly AsyncLocal<DbContextOptionsFactoryContext> _current = new AsyncLocal<DbContextOptionsFactoryContext>(); |
|||
|
|||
public string ConnectionStringName { get; } |
|||
|
|||
public string ConnectionString { get; } |
|||
|
|||
public DbContextOptionsFactoryContext(string connectionStringName, string connectionString) |
|||
{ |
|||
ConnectionStringName = connectionStringName; |
|||
ConnectionString = connectionString; |
|||
} |
|||
|
|||
public static IDisposable Use(DbContextOptionsFactoryContext context) |
|||
{ |
|||
_current.Value = context; |
|||
return new DisposeAction(() => _current.Value = null); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,57 @@ |
|||
namespace Volo.Abp.Uow |
|||
using System; |
|||
using System.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Uow |
|||
{ |
|||
public class UnitOfWorkStartOptions |
|||
{ |
|||
//Revise this since Begin/BeginReserved accepts different options and that can make confusion!
|
|||
|
|||
public bool RequiresNew { get; set; } |
|||
|
|||
public string ReservationName { get; set; } |
|||
|
|||
public bool? IsTransactional { get; set; } |
|||
|
|||
public IsolationLevel? IsolationLevel { get; set; } |
|||
|
|||
public TimeSpan? Timeout { get; set; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Global (default) unit of work options
|
|||
/// </summary>
|
|||
public class UnitOfWorkOptions |
|||
{ |
|||
public IUnitOfWorkTransactionBehavior IsTransactional { get; set; } |
|||
|
|||
public IsolationLevel? IsolationLevel { get; set; } |
|||
} |
|||
|
|||
public interface IUnitOfWorkTransactionBehavior |
|||
{ |
|||
UnitOfWorkStartOptions Set(UnitOfWorkTransactionBehaviorContext context); |
|||
} |
|||
|
|||
public class ConventionalUnitOfWorkTransactionBehavior : IUnitOfWorkTransactionBehavior |
|||
{ |
|||
public UnitOfWorkStartOptions Set(UnitOfWorkTransactionBehaviorContext context) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
public class UnitOfWorkTransactionBehaviorContext : IServiceProviderAccessor |
|||
{ |
|||
public UnitOfWorkStartOptions Options { get; } |
|||
|
|||
public IServiceProvider ServiceProvider { get; } |
|||
|
|||
public UnitOfWorkTransactionBehaviorContext(UnitOfWorkStartOptions options, IServiceProvider serviceProvider) |
|||
{ |
|||
Options = options; |
|||
ServiceProvider = serviceProvider; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue