Example #1
0
 protected P_StorageOpCtxBase(P_StorageOpCtx baseCtx)
     : base(outerDependencies: baseCtx.EnsureNotNull(nameof(baseCtx)).Value.DataContext)
 {
     _dataCtx     = baseCtx.DataContext;
     _efCtxGetter = baseCtx.GetDataChangeEfDbContext;
     _efCtxLazy   = new DisposableLazy <TEfDbContext>(factory: P_GetDataChangeEfDbContext, ownsValue: false);
 }
Example #2
0
 protected P_StorageOpCtxBase(PersistenceEfCoreDataContext <TEfDbContext> dataCtx, TEfDbContext efCtx)
     : base(outerDependencies: dataCtx.EnsureNotNull(nameof(dataCtx)).Value)
 {
     efCtx.EnsureNotNull(nameof(efCtx));
     //
     _dataCtx     = dataCtx;
     _efCtxGetter = null;
     _efCtxLazy   = new DisposableLazy <TEfDbContext>(value: efCtx, ownsValue: false);
 }
Example #3
0
 protected override void Dispose(bool explicitDispose)
 {
     if (explicitDispose)
     {
         _efCtxLazy?.Dispose();
     }
     _dataCtx     = null;
     _efCtxLazy   = null;
     _efCtxGetter = null;
     //
     base.Dispose(explicitDispose);
 }
Example #4
0
        public async Task <IPersistenceDataContext <TEfDbContext> > CreateContextAsync(IContext ctx = default)
        {
            ctx.ThrowIfCancellationRequested();
            //
            PersistenceEfCoreDataContext <TEfDbContext> dataContext = default;

            try {
                dataContext = await DoCreateContextAsync(ctx : ctx).ConfigureAwait(false);
                await OnAdjustContextAsync(dataContext : dataContext, ctx : ctx).ConfigureAwait(false);

                //
                ctx.ThrowIfCancellationRequested();
                //
                return(dataContext);
            }
            catch (Exception exception) {
                dataContext?.Dispose(exception);
                throw;
            }
        }
Example #5
0
 protected virtual async Task OnAdjustContextAsync(PersistenceEfCoreDataContext <TEfDbContext> dataContext, IContext ctx = default)
 {
     dataContext.EnsureNotNull(nameof(dataContext));
     //
     await Task.CompletedTask;
 }
Example #6
0
 internal P_StorageOpCtx(PersistenceEfCoreDataContext <TEfDbContext> dataCtx, TEfDbContext efCtx)
     : base(dataCtx: dataCtx, efCtx: efCtx)
 {
     _strictedCtxs         = new Dictionary <PersistenceEntityReferenceKeyTypeDescriptor, P_StorageOpCtxBase>();
     _strictedCtxsSpinLock = new PrimitiveSpinLock();
 }