public IDbContext CreateContext(string connString) { IDbContext dbContext = null; var dbType = this.DbType == null ? "" : this.DbType.ToLower(); switch (dbType) { case "sqlite": dbContext = CreateSQLiteContext(connString); break; case "sqlserver": dbContext = CreateSqlServerContext(connString); break; default: dbContext = CreateSqlServerContext(connString); break; } IDbCommandInterceptor interceptor = new DbCommandInterceptor(); dbContext.Session.AddInterceptor(interceptor); return(dbContext); }
static DbContextFactory() { ConnectionString = Globals.Configuration["db:ConnString"]; string dbType = Globals.Configuration["db:DbType"]; if (string.IsNullOrEmpty(dbType) == false) { DbType = dbType.ToLower(); } #if DEBUG IDbCommandInterceptor interceptor = new DbCommandInterceptor(); DbInterception.Add(interceptor); #endif }