internal static DbConfiguration Get(DbContextOption dbContextOption)
        {
            Guard.NotNull(dbContextOption, "dbContextOption");
            DbConfiguration cfg;

            items.TryGetValue(dbContextOption.Container, out cfg);
            if (cfg == null)
            {
                //自动配置
                cfg = DbConfiguration.Configure(dbContextOption);
            }
            //if(cfg.sqlLogger == null)
            //{
            //    cfg.sqlLogger = dbContextOption.Logger;
            //}
            return(cfg);
        }
Example #2
0
        /// <summary>
        /// 得到工作单元对象
        /// </summary>
        /// <param name="dbContextOption">配置信息</param>
        /// <returns></returns>
        public static IDbContext Get(DbContextOption dbContextOption)
        {
            Guard.NotNullOrEmpty(dbContextOption.Container, "dbConfigurationName");

            return(DbConfiguration.Configure(dbContextOption).CreateDbContext());
        }
 /// <summary>
 ///  配置Oracle ODP
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="isDefault"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureOracleODP(string connectionString, bool isDefault)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.Oracle_ODP, isDefault));
 }
 /// <summary>
 /// 配置SqlServer
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="isDefault"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSqlServer(string connectionString, bool isDefault)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.SqlServer, isDefault));
 }
 /// <summary>
 /// 配置MySQL
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="isDefault"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureMySQL(string connectionString, bool isDefault)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.MySQL, isDefault));
 }
 /// <summary>
 /// 配置SQLite
 /// </summary>
 /// <param name="databaseFile"></param>
 /// <param name="password"></param>
 /// <param name="failIfMissing"></param>
 /// <param name="isDefault"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSQLite(string databaseFile, string password, bool failIfMissing, bool isDefault)
 {
     return(DbConfiguration.Configure(BuildSQLiteConnectionString(databaseFile, password, failIfMissing), DbProviderNames.SQLite, isDefault));
 }