public static TkDbContext CreateDefault() { ISupportDbContext support = GetSupport(); DbContextConfig config = support.Default; TkDebug.AssertNotNull(config, "AppSetting中没有配置Default的DbContext", support); return(config.CreateDbContext()); }
private static ISupportDbContext GetSupport() { TkDebug.ThrowIfNoAppSetting(); ISupportDbContext support = BaseAppSetting.Current as ISupportDbContext; TkDebug.AssertNotNull(support, "AppSetting不支持ISupportDbContext接口,无法创建DbContext", BaseAppSetting.Current); return(support); }
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 GetDbContextConfig(string name) { ISupportDbContext support = GetSupport(); if (string.IsNullOrEmpty(name)) { return(support.Default); } else { return(support.GetContextConfig(name)); } }
protected override object InternalConvertFromString(string text, ReadSettings settings) { ISupportDbContext support = BaseAppSetting.Current as ISupportDbContext; if (support == null) { return(null); } if (string.IsNullOrEmpty(text)) { return(support.Default); } return(support.GetContextConfig(text)); }