public virtual IEnumerable <TEntity> ExecuteQuery(string query) { try { context = new UnitOfWorkDevelopmentEntities(); dbSet = context.Set <TEntity>(); return(dbSet.SqlQuery(query)); } catch (Exception) { return(null); } }
public virtual void Delete(object id) { try { context = new UnitOfWorkDevelopmentEntities(); dbSet = context.Set <TEntity>(); TEntity entityToDelete = dbSet.Find(id); Delete(entityToDelete); } catch (Exception) { } }
public virtual TEntity Insert(TEntity entity) { context = new UnitOfWorkDevelopmentEntities(); dbSet = context.Set <TEntity>(); var response = dbSet.Add(entity); context.SaveChanges(); return(response); //return new Response //{ // Success = (output == 0) ? true : false, // Result = output, // Exception = (output != 0) ? "Error Inserting into database" : string.Empty //}; }
public virtual TEntity Update(TEntity entity) { try { context = new UnitOfWorkDevelopmentEntities(); dbSet = context.Set <TEntity>(); var result = dbSet.Attach(entity); context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(result); } catch (Exception) { return(null); } }
internal TEntity GetById(object id) { context = new UnitOfWorkDevelopmentEntities(); dbSet = context.Set <TEntity>(); return(dbSet.Find(id)); }