Ejemplo n.º 1
0
        public WebDatabase(DbConnectionConfig dbConnectionConfig)
        {
            this.dbConnectionConfig = dbConnectionConfig;

            dbProvider = dbConnectionConfig.DbProvider;
            connectionString = dbConnectionConfig.ConnectionString;
        }
Ejemplo n.º 2
0
        public static IDatabase GetDbObject(DbConnectionConfig DbConnectionConfig)
        {
            bool isWebApplication = Environment.ApplicationType == ApplicationType.WebApplication;

            if(isWebApplication)
                return new WebDatabase(DbConnectionConfig);
            else
                return new Database(DbConnectionConfig);
        }
        public ConnectionStringParser(DbConnectionConfig dbConnectionConfig)
        {
            DbProvider dbProvider = dbConnectionConfig.DbProvider;
            string connectionString = dbConnectionConfig.ConnectionString;

            switch (dbProvider)
            {
                case DbProvider.MySql: { throw new NotImplementedException(); }
                case DbProvider.Teradata: { throw new NotImplementedException(); }
                case DbProvider.Sqlite: { throw new NotImplementedException(); }

                case DbProvider.SqlServer:
                    {
                        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);

                        DataSource = builder.DataSource;
                        UserID = builder.UserID;
                        Password = builder.Password;
                    } break;

                case DbProvider.Oracle:
                    {
                        OracleConnectionStringBuilder builder = new OracleConnectionStringBuilder(connectionString);

                        DataSource = builder.DataSource;
                        UserID = builder.UserID;
                        Password = builder.Password;
                    } break;

                case DbProvider.OleDb:
                    {
                        OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(connectionString);
                        DataSource = builder.DataSource;
                        UserID = builder["UserID"].ToString();
                        Password = builder["Password"].ToString();
                    } break;
            }
        }
        private static IDatabase GetDbObject()
        {
            if (false == JUtil.Path.File.Exists(DbPath))
                throw new Exception(string.Format("Can not find any Sqlite database in path {0}", DbPath));

            DbConnectionConfig dbConnectionConfig = new DbConnectionConfig { ConnectionString = String.Format("Data Source={0};Version=3;", DbPath), DbProvider = DbProvider.Sqlite };

            IDatabase db = DbUtil.GetNoneHoldingConnectionDb(dbConnectionConfig);

            return db;
        }
Ejemplo n.º 5
0
 public static IDatabase GetNoneHoldingConnectionDb(DbConnectionConfig DbConnectionConfig)
 {
     return new WebDatabase(DbConnectionConfig);
 }
Ejemplo n.º 6
0
 public DbUtil(DbConnectionConfig DbConnectionConfig)
 {
     this.db = GetDbObject(DbConnectionConfig);
 }