Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Database"/> class.
        /// </summary>
        /// <param name="dbProvider">The db provider.</param>
        public Database(DbProviders.DbProvider dbProvider)
        {
            Check.Require(dbProvider != null, "dbProvider could not be null.");

            this.dbProvider = dbProvider;
            this.queryFactory = dbProvider.GetQueryFactory();
        }
Ejemplo n.º 2
0
 static DbProviderFactory()
 {
     try
     {
         ConnectionStringSettings connStrSetting = ConfigurationManager.ConnectionStrings[ConfigurationManager.ConnectionStrings.Count - 1];
         string[] assAndClass = connStrSetting.ProviderName.Split(',');
         if (assAndClass.Length > 1)
         {
             _Default = CreateDbProvider(assAndClass[1].Trim(), assAndClass[0].Trim(), connStrSetting.ConnectionString);
         }
         else
         {
             _Default = CreateDbProvider(null, assAndClass[0].Trim(), connStrSetting.ConnectionString);
         }
     }
     catch
     {
         _Default = null;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Database"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="connectionString">The connection string.</param>
 public Database(DatabaseType type, string connectionString)
 {
     Check.Require(!string.IsNullOrEmpty(connectionString), "connectionString could not be null or empty.");
     //switch (type)
     //{
     //    case DatabaseType.MsAccess:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider(null, typeof(DbProviders.MsAccess.AccessDbProvider).ToString(), connectionString);
     //        break;
     //    case DatabaseType.SqlServer:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider(null, typeof(DbProviders.SqlServer.SqlDbProvider).ToString(), connectionString);
     //        break;
     //    case DatabaseType.SqlServer9:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider(null, typeof(DbProviders.SqlServer.SqlDbProvider9).ToString(), connectionString);
     //        break;
     //    case DatabaseType.MySql:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider("NBearLite.AdditionalDbProviders", "NBearLite.DbProviders.MySql.MySqlDbProvider", connectionString);
     //        break;
     //    case DatabaseType.Oracle:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider(null, typeof(DbProviders.Oracle.OracleDbProvider).ToString(), connectionString);
     //        break;
     //    case DatabaseType.Sqlite:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider("NBearLite.AdditionalDbProviders", "NBearLite.DbProviders.Sqlite.SqliteDbProvider", connectionString);
     //        break;
     //    case DatabaseType.PostgreSql:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider("NBearLite.AdditionalDbProviders", "NBearLite.DbProviders.PostgreSql.PostgreSqlDbProvider", connectionString);
     //        break;
     //    case DatabaseType.DB2:
     //        this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider("NBearLite.AdditionalDbProviders", "NBearLite.DbProviders.DB2.DB2DbProvider", connectionString);
     //        break;
     //    default:
     //        throw new NotSupportedException("Unknow DatabaseType.");
     //}
     this.dbProvider = new DbProviders.SqlServer.SqlDbProvider9(connectionString);
     this.queryFactory = dbProvider.GetQueryFactory();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Database"/> class.
 /// </summary>
 /// <param name="connectionStringName">Name of the connection string.</param>
 public Database(string connectionStringName)
 {
     this.dbProvider = DbProviders.DbProviderFactory.CreateDbProvider(connectionStringName);
     this.queryFactory = dbProvider.GetQueryFactory();
 }
Ejemplo n.º 5
0
 static DbProviderFactory()
 {
     ConnectionStringSettings connStrSetting = ConfigurationManager.ConnectionStrings[ConfigurationManager.ConnectionStrings.Count - 1];
     _Default = new SqlServer.SqlDbProvider9(connStrSetting.ConnectionString);
 }