public UsersController(
     IDbContextAccessor dbContextAccessor,
     IUnitOfWork unitOfWork,
     UserContext userContext)
 {
     this.dbContextAccessor = dbContextAccessor;
     this.unitOfWork        = unitOfWork;
     this.userContext       = userContext;
 }
Esempio n. 2
0
 public TasksController(
     UserContext userContext,
     IUnitOfWork unitOfWork,
     ITasksRepository tasksRepository,
     IDbContextAccessor dbContextAccessor)
 {
     this.userContext       = userContext;
     this.unitOfWork        = unitOfWork;
     this.tasksRepository   = tasksRepository;
     this.dbContextAccessor = dbContextAccessor;
 }
        // private readonly TransactionScope _transaction;

        public HandlingScope(IDiContainerAccessor containerAccessor, HandlerIdentity identity)
        {
            Identity             = identity;
            _containerAccessor   = containerAccessor;
            _contextAccessor     = _containerAccessor.GetInstance <IDbContextAccessor>();
            _handlingScopesStack = _containerAccessor.GetInstance <IHandlingScopesStack <HandlingScope> >();

            _parentScope = _handlingScopesStack.GetCurrentScope();
            _handlingScopesStack.EnterScope(this);

            // _transaction = new TransactionScope(TransactionScopeOption.Required,
            //      new TransactionOptions {IsolationLevel = IsolationLevel.Snapshot});
        }
Esempio n. 4
0
        private static void SetCurrentUow(IDbContextAccessor value)
        {
            lock (AsyncLocalUow)
            {
                if (value == null)
                {
                    if (AsyncLocalUow.Value == null)
                    {
                        return;
                    }

                    if (AsyncLocalUow.Value.UnitOfWork?.Outer == null)
                    {
                        AsyncLocalUow.Value.UnitOfWork = null;
                        AsyncLocalUow.Value            = null;
                        return;
                    }

                    AsyncLocalUow.Value.UnitOfWork = AsyncLocalUow.Value.UnitOfWork;
                }
                else
                {
                    if (AsyncLocalUow.Value?.UnitOfWork == null)
                    {
                        if (AsyncLocalUow.Value != null)
                        {
                            AsyncLocalUow.Value.UnitOfWork = value;
                        }

                        AsyncLocalUow.Value = new LocalUowWrapper(value);
                        return;
                    }

                    value.Outer = AsyncLocalUow.Value.UnitOfWork.Outer;
                    AsyncLocalUow.Value.UnitOfWork = value;
                }
            }
        }
Esempio n. 5
0
 public AggregateRepository(IDbContextAccessor dbContextAccessor)
 {
     this.dbContextAccessor = dbContextAccessor;
 }
Esempio n. 6
0
 public LocalUowWrapper(IDbContextAccessor unitOfWork)
 {
     UnitOfWork = unitOfWork;
 }
 public GenericEntityRepository(IDbContextAccessor contextAccessor)
 {
     _contextAccessor = contextAccessor;
     _setAccessor     = contextAccessor.Set <T>();
 }
Esempio n. 8
0
 public TaskNomsController(IDbContextAccessor accessor, UserContext userContext)
 {
     this.accessor    = accessor;
     this.userContext = userContext;
 }
 public EntityReader(IDbContextAccessor contextAccessor)
 {
     _setAccessor = contextAccessor.Set <TEntity>();
     _queryable   = _setAccessor.NotTracked();
 }
Esempio n. 10
0
 public EfUnitOfWork(IDbContextAccessor dbContextAccessor)
 {
     _dbContext = dbContextAccessor.Context;
 }
Esempio n. 11
0
 public OrderRepo(IDbContextAccessor <ReferenceDbContext> dbContextAccessor)
 {
     this.DbContextAccessor = dbContextAccessor ?? throw new ArgumentNullException(nameof(dbContextAccessor));
 }
Esempio n. 12
0
 public EfRepository(IDbContextAccessor contextAccessor)
 {
     Context = contextAccessor.Context;
     DbSet   = Context.Set <TEntity>();
 }
 public TasksRepository(IDbContextAccessor dbContextAccessor)
     : base(dbContextAccessor)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// This repository in the infrastructure/persistence layer has an <see cref="IDbContextAccessor{TDbContext}"/> injected.
 /// This gives it access to the <see cref="Microsoft.EntityFrameworkCore.DbContext"/> provided and managed by a service higher up the call stack, usually in the orchestrating layer.
 /// </summary>
 public OrderRepository(IDbContextAccessor <ExampleDbContext> dbContextAccessor)
 {
     this.DbContextAccessor = dbContextAccessor ?? throw new ArgumentNullException(nameof(dbContextAccessor));
 }