Exemple #1
0
        public static TkDbContext CreateDefault()
        {
            ISupportDbContext support = GetSupport();
            DbContextConfig   config  = support.Default;

            TkDebug.AssertNotNull(config, "AppSetting中没有配置Default的DbContext", support);
            return(config.CreateDbContext());
        }
Exemple #2
0
        private static ISupportDbContext GetSupport()
        {
            TkDebug.ThrowIfNoAppSetting();

            ISupportDbContext support = BaseAppSetting.Current as ISupportDbContext;

            TkDebug.AssertNotNull(support, "AppSetting不支持ISupportDbContext接口,无法创建DbContext",
                                  BaseAppSetting.Current);
            return(support);
        }
Exemple #3
0
        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());
        }
Exemple #4
0
        public static DbContextConfig GetDbContextConfig(string name)
        {
            ISupportDbContext support = GetSupport();

            if (string.IsNullOrEmpty(name))
            {
                return(support.Default);
            }
            else
            {
                return(support.GetContextConfig(name));
            }
        }
Exemple #5
0
        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));
        }