Beispiel #1
0
 public DbSet <TEntity> CreateSet(DbConfig config, DbMode mode)
 {
     if (_dbContext == null)
     {
         _dbContext = _contextFactory.Create(_dbFactory.GetDbInitContext(typeof(TEntity), mode, config));
     }
     return(_dbContext.Set <TEntity>());
 }
Beispiel #2
0
 public void Dispose()
 {
     if (_isDisposed)
     {
         return;
     }
     _dbContext?.Dispose();
     _contextFactory.DisposeDbContext(_dbContext?.CacheKey);
     _dbContext  = null;
     _isDisposed = true;
 }
Beispiel #3
0
 public ContextFactory()
 {
     if (_creator == null)
     {
         _creator = (item, context) =>
         {
             var dbContext = new CoralDbContext(context);
             return(dbContext);
         }
     }
     ;
 }