public static TkDbContext CreateDefault() { ISupportDbContext support = GetSupport(); DbContextConfig config = support.Default; TkDebug.AssertNotNull(config, "AppSetting中没有配置Default的DbContext", support); return(config.CreateDbContext()); }
public static TkDbContext CreateDbContext(string name) { TkDebug.AssertArgumentNullOrEmpty(name, "name", null); ISupportDbContext support = GetSupport(); DbContextConfig config = support.GetContextConfig(name); TkDebug.AssertNotNull(config, string.Format(ObjectUtil.SysCulture, "AppSetting中没有配置名称为{0}的DbContext", name), support); return(config.CreateDbContext()); }
public static DbContextConfig Create(string name, string sqlProvider, string dbProvider, string connectionString) { TkDebug.AssertArgumentNullOrEmpty(sqlProvider, "sqlProvider", null); TkDebug.AssertArgumentNullOrEmpty(dbProvider, "dbProvider", null); TkDebug.AssertArgumentNullOrEmpty(connectionString, "connectionString", null); TkDebug.ThrowIfNoGlobalVariable(); DbContextConfig config = new DbContextConfig { Name = name, SqlProvider = sqlProvider, DbProvider = dbProvider, ConnectionString = connectionString }; return(config); }
internal TkDbContext(DbContextConfig contextConfig, IDbConnection connection) { fContextConfig = contextConfig; DbConnection = connection; fCreateConnection = false; }
internal TkDbContext(DbContextConfig contextConfig) { fContextConfig = contextConfig; DbConnection = contextConfig.CreateConnection(); fCreateConnection = true; }