static DBHelper getDBHelper(DbContext dbContext) { var dbConnection = dbContext.Database.GetDbConnection(); var builder = DBConfigRegister.GetInstance(); builder.RegisterDBAccessBuild(dbLocation => { return(new DBAccessBuild(DBType.MSSQL, dbConnection)); }); var dbConnectionTypeName = dbConnection.GetType().Name; DBType dBType = DBType.MSSQL; switch (dbConnectionTypeName) { case "SqlConnection": dBType = DBType.MSSQL; break; case "MySqlConnection": dBType = DBType.MYSQL; break; case "OracleConnection": dBType = DBType.ORACLE; break; } var dBAccessBuild = new DBAccessBuild(dBType, dbConnection); var helper = DBConfigRegister.GetDBHelper(dBAccessBuild); return(helper); }
public MongoDBHelper(DBAccessBuild dBAccessBuild) : base(dBAccessBuild) { var _connectionString = dBAccessBuild._connectionString; var lastIndex = _connectionString.LastIndexOf("/"); var dataBaseName = _connectionString.Substring(lastIndex + 1);//like mongodb://localhost:27017/db1 _dataBaseName = dataBaseName; }
public DBHelper(DBAccessBuild dBAccessBuild) { if (dBAccessBuild._connection != null) { AutoCloseConn = false; currentConn = dBAccessBuild._connection; return; } if (string.IsNullOrEmpty(dBAccessBuild._connectionString)) { throw new Exception("连接字符串为空"); } _params = new Dictionary <string, object>(); ConnectionString = dBAccessBuild._connectionString; }
public OracleHelper(DBAccessBuild dBAccessBuild) : base(dBAccessBuild) { }
/// <summary> /// 根据参数类型实例化 /// </summary> /// <param name="_connectionString">内容</param> public SqlHelper(DBAccessBuild dBAccessBuild) : base(dBAccessBuild) { }