public void remove(params T[] items) { using (var context = new dsStaffModel()) { foreach (T item in items) { context.Entry(item).State = System.Data.Entity.EntityState.Deleted; } context.SaveChanges(); } }
public T GetSingle(Func <T, bool> where, params System.Linq.Expressions.Expression <Func <T, object> >[] navigationproperties) { T item = null; using (var context = new dsStaffModel()) { IQueryable <T> dbquery = context.Set <T>(); // eager loading foreach (Expression <Func <T, object> > navigationProperty in navigationproperties) { dbquery = dbquery.Include <T, object>(navigationProperty); } item = dbquery.AsNoTracking().SingleOrDefault(where); } return(item); }
public IList <T> GetList(Func <T, bool> where, params System.Linq.Expressions.Expression <Func <T, object> >[] navigationproperties) { List <T> list = null; using (var context = new dsStaffModel()) { IQueryable <T> dbquery = context.Set <T>(); // eager loading foreach (Expression <Func <T, object> > navigationProperty in navigationproperties) { dbquery = dbquery.Include <T, object>(navigationProperty); } list = dbquery.AsNoTracking().Where(where).ToList <T>(); } return(list); }