public MySqlCommand CreateSqlCommand(string query, IMySqlDbContext dbContext, IEnumerable <MySqlParameter> sqlParams = null, CommandType commandType = CommandType.StoredProcedure) { try { MySqlCommand command = new MySqlCommand(query, dbContext.Connection); command.CommandType = commandType; if (dbContext.TransactionEnabled) { command.Transaction = dbContext.Transaction; } if (sqlParams != null) { for (int i = 0; i < sqlParams.Count(); i++) { command.Parameters.Add(sqlParams.ElementAt(i)); } } return(command); } catch (Exception ex) { throw new Exception(string.Format("Error > \"{0}\" {1} Error Type > \"{2}\" {3} Method > \"CreateSqlCommand\"{4} Class > {5}", ex.Message, Environment.NewLine, ex.GetType().ToString(), Environment.NewLine, Environment.NewLine, this.GetType().ToString()), ex); } }
public UserRepository( IMySqlDbContext db, IMySqlCommandProvider <User> commandProvider, IMySqlObjectBuilder <User> objectBuilder) : base(db, commandProvider, objectBuilder) { }
public void Setup() { _dbContext = new MySqlDbContext(); _dbContext.Connect("server=localhost;userid=jestin;password=crudnet;database=crudnet_test"); _commandProvider = new UserCommandProvider(); _objectBuilder = new UserObjectBuilder(); _userRepository = new UserRepository(_dbContext, _commandProvider, _objectBuilder); }
protected BaseMySqlRepository( IMySqlDbContext dbContext, IMySqlCommandProvider <T> commandProvider, IMySqlObjectBuilder <T> objectBuilder) { Db = dbContext; CommandProvider = commandProvider; ObjectBuilder = objectBuilder; }
protected LongIdentifiableMySqlRepository( IMySqlDbContext dbContext, IMySqlCommandProvider <T> commandProvider, IMySqlObjectBuilder <T> objectBuilder) : base(dbContext, commandProvider, objectBuilder) { Db = dbContext; CommandProvider = commandProvider; ObjectBuilder = objectBuilder; }
protected void Application_BeginRequest(object sender, EventArgs e) { if (AppContext.DbContext == null) { ICacheManager cacheManager = EngineContext.Current.Resolve <ICacheManager>(); IMySqlDbContext dbContext = EngineContext .Current .Resolve <IMySqlDataProvider>() .GetDbContext( new ConnectionParams() { Host = EngineContext.Configurations.Host, Database = EngineContext.Configurations.Database, Username = EngineContext.Configurations.DbUsername, Password = EngineContext.Configurations.DbPassword, Port = EngineContext.Configurations.DbPort }); cacheManager.Set(Keys.DatabaseKey, dbContext, 1080); } IMySqlDbContext mySqlDbContext = (IMySqlDbContext)AppContext.DbContext.Clone(); mySqlDbContext.OpenConnection(true); HttpContext.Current.Items.Add(Keys.DatabaseKey, AppContext.DbContext); }
public VaultSqlHelper(IMySqlDbContext dbContext, IMySqlDbClient mySqlDbClient) { this._dbContext = dbContext; this._dbClient = mySqlDbClient; }