예제 #1
0
        public SimpleDbContextProvider(DbContextBase dbContext, IDbContextConfiguration configuration, ICurrentUser currentUser)
        {
            DbContext = dbContext;

            // Set current user if is auth
            DbContext.CurrentUser = currentUser;

            // Do NOT enable proxied entities, else serialization fails
            DbContext.Configuration.ProxyCreationEnabled = configuration.ProxyCreationEnabled;

            // Load navigation properties explicitly (avoid serialization trouble)
            DbContext.Configuration.LazyLoadingEnabled = configuration.LazyLoadingEnabled;

            // Because Web API will perform validation, we don't need/want EF to do so
            DbContext.Configuration.ValidateOnSaveEnabled = configuration.ValidateOnSaveEnabled;

            //DbContext.Configuration.AutoDetectChangesEnabled = false;
            // We won't use this performance tweak because we don't need
            // the extra performance and, when autodetect is false,
            // we'd have to be careful. We're not being that careful.
        }
예제 #2
0
 public UnitOfWork(IDbContextConfiguration <TContext> dbContextConfiguration)
 {
     _dataContext = new TContext();
     _dataContext.DataAccessConfiguration = dbContextConfiguration.GetDataAccessConfiguration();
     _repositories = new Dictionary <Type, object>();
 }
 public AmbientDbContextConfigurator(IAmbientDbContextLocator ambientDbContextLocator,
                                     IDbContextConfiguration configuration)
 {
     this.ambientDbContextLocator = ambientDbContextLocator;
     this.configuration           = configuration;
 }