Exemple #1
0
 //--  DeletePermanent (T entity)
 public virtual bool DeletePermanent(T entity)
 {
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         return(context.Connection.Delete(entity));
     }
 }
Exemple #2
0
 //--  DeletePermanentAsync (T entity)
 public virtual async Task <bool> DeletePermanentAsync(T entity)
 {
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         return(await context.Connection.DeleteAsync(entity));
     }
 }
 //--  InsertAsync (T entity)
 public virtual async Task <object> InsertAsync(T entity)
 {
     entity = SetIncludeData(entity);
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         return(await context.Connection.InsertAsync(entity));
     }
 }
 //--  UpdateAsync (T entity)
 public virtual async Task <bool> UpdateAsync(T entity)
 {
     entity = SetAlterData(entity);
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         return(await context.Connection.UpdateAsync(entity));
     }
 }
 //--  Update (T entity)
 public virtual bool Update(T entity)
 {
     entity = SetAlterData(entity);
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         return(context.Connection.Update(entity));
     }
 }
 //--  Insert (T entity)
 public virtual T Insert(T entity)
 {
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         entity    = SetIncludeData(entity);
         entity.Id = Convert.ToInt32(context.Connection.Insert(entity));
         return(entity);
     }
 }
Exemple #7
0
 //--  DeletePermanent (int id)
 public virtual bool DeletePermanent(int id)
 {
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         var obj = Activator.CreateInstance <T>();
         obj.Id = id;
         return(context.Connection.Delete(obj));
     }
 }
Exemple #8
0
 //--  DeletePermanentAsync (int id)
 public virtual async Task <bool> DeletePermanentAsync(int id)
 {
     using (var context = DBRepository.ReturnMySqlContext(_connectionString))
     {
         var obj = Activator.CreateInstance <T>();
         obj.Id = id;
         return(await context.Connection.DeleteAsync(obj));
     }
 }
 public T ExecuteProcedureFirst(string storedProcedure, object objParameters = null, int?timeout = 120, IMySQLContext dbContext = null, bool buffered = true)
 {
     if (dbContext == null)
     {
         using (var context = DBRepository.ReturnMySqlContext(_connectionString))
         {
             return(context.Connection.QueryFirstOrDefault <T>(storedProcedure, objParameters, null, timeout, CommandType.StoredProcedure));
         }
     }
     else
     {
         return(dbContext.Connection.QueryFirstOrDefault <T>(storedProcedure, objParameters, dbContext.Transaction, timeout, CommandType.StoredProcedure));
     }
 }
 public async Task <SqlMapper.GridReader> ExecuteProcedureMultipleAsync(string storedProcedure, object objParameters = null, int?timeout = 120, IMySQLContext dbContext = null, bool buffered = true)
 {
     if (dbContext == null)
     {
         using (var context = DBRepository.ReturnMySqlContext(_connectionString))
         {
             return(await context.Connection.QueryMultipleAsync(storedProcedure, objParameters, null, timeout, CommandType.StoredProcedure));
         }
     }
     else
     {
         return(await dbContext.Connection.QueryMultipleAsync(storedProcedure, objParameters, dbContext.Transaction, timeout, CommandType.StoredProcedure));
     }
 }
 public async Task <IEnumerable <T> > ExecuteProcedureAsync(string storedProcedure, object objParameters = null, int?timeout = 120, IMySQLContext dbContext = null)
 {
     if (dbContext == null)
     {
         using (var context = DBRepository.ReturnMySqlContext(_connectionString))
         {
             return(await context.Connection.QueryAsync <T>(storedProcedure, objParameters, null, timeout, CommandType.StoredProcedure));
         }
     }
     else
     {
         return(await dbContext.Connection.QueryAsync <T>(storedProcedure, objParameters, dbContext.Transaction, timeout, CommandType.StoredProcedure));
     }
 }
Exemple #12
0
 public virtual IEnumerable <T> GetAll()
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(GetAll(dbContext));
 }
 public IMySQLContext NewConnection(string connectionString)
 {
     _connectionString = connectionString;
     return(DBRepository.ReturnMySqlContext(_connectionString));
 }
Exemple #14
0
 public virtual async Task <IEnumerable <T> > GetAllAsync()
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(await GetAllAsync(dbContext));
 }
Exemple #15
0
 public virtual async Task <T> GetByIdAsync(int id)
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(await GetByIdAsync(id, dbContext));
 }
Exemple #16
0
 public virtual T SelectFirst <TKey>(Expression <Func <T, bool> > linqExpression, bool ascOrder, Func <T, TKey> orderExpression)
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(SelectFirst(linqExpression, ascOrder, orderExpression, dbContext));
 }
Exemple #17
0
 public virtual IEnumerable <T> Select(Expression <Func <T, bool> > linqExpression)
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(Select(linqExpression, dbContext));
 }
Exemple #18
0
 public virtual T GetById(int id)
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(GetById(id, dbContext));
 }
Exemple #19
0
 public virtual async Task <T> SelectFirstAsync(Expression <Func <T, bool> > linqExpression)
 {
     using var dbContext = DBRepository.ReturnMySqlContext(_connectionString);
     return(await SelectFirstAsync(linqExpression, dbContext));
 }