public override T FindById(IdT id) { using (var db = new NgContext()) { var _dbSet = db.Set <T>(); return(_dbSet.Find(id)); } }
public override void Edit(T entity) { using (var db = new NgContext()) { var dbSet = db.Set <T>(); dbSet.Update(entity); } }
public override ICollection <T> FindAll() { using (var db = new NgContext()) { var _dbSet = db.Set <T>(); return(_dbSet.ToList()); } }
public override T Find(Func <T, bool> expression) { using (var db = new NgContext()) { var _dbSet = db.Set <T>(); return(_dbSet.FirstOrDefault(expression)); } }
public override T Find(Expression <Func <T, object> > expression, Func <object, bool> func) { using (var db = new NgContext()) { var _dbSet = db.Set <T>().Select(expression).AsEnumerable().FirstOrDefault(func); return((T)_dbSet); } }
public override T Find(Expression <Func <T, object> > expression, int id) { using (var db = new NgContext()) { var _dbSet = db.Set <T>().Select(expression).ToList().FirstOrDefault(t => (t as T).Id == id); return((T)_dbSet); } }
public override void Add(T entity) { using (var db = new NgContext()) { var _dbSet = db.Set <T>(); _dbSet.Add(entity); db.SaveChanges(); } }
public override ICollection <T> FindAll(Expression <Func <T, object> > expression) { using (var db = new NgContext()) { db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var _dbSet = db.Set <T>().Select(expression).AsNoTracking().ToList(); return(_dbSet.Cast <T>().ToList()); } }
public override ICollection <T> FindAll() { using (var db = new NgContext()) { db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var _dbSet = db.Set <T>(); return(_dbSet.ToList()); } }
public override void Save(T entity) { using (var db = new NgContext()) { var dbSet = db.Set <T>(); db.Update(entity); db.SaveChanges(); } }
public override T FindById(int id) { using (var db = new NgContext()) { db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var _dbSet = db.Set <T>(); return(_dbSet.Find(id)); } }
public override ICollection <T> FindAll(Func <T, bool> expression) { using (var db = new NgContext()) { db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var _dbSet = db.Set <T>(); return(_dbSet.ToList().Where(expression).ToList()); } }
public override int Add(T entity) { using (var db = new NgContext()) { var _dbSet = db.Set <T>(); var item = _dbSet.Add(entity); db.SaveChanges(); return(item.Entity.Id); } }
public override void Delete(IdT id) { using (var db = new NgContext()) { var dbSet = db.Set <T>(); dbSet.Remove(new T() { Id = id }); db.SaveChanges(); } }
public override void Delete(int id) { using (var db = new NgContext()) { db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var dbSet = db.Set <T>(); dbSet.Remove(new T() { Id = id }); db.SaveChanges(); } }
public override ICollection <T> FindAll(EntityExpression <T> entityExpression, Func <T, bool> func = null) { using (var db = new NgContext()) { var _dbSet = db.Set <T>().Include(entityExpression.ExpressionList.First()); foreach (var exp in entityExpression.ExpressionList) { _dbSet = _dbSet.Include(exp); } if (func != null) { return(_dbSet.Where(func).ToList()); } return(_dbSet.ToList()); } }