public virtual IList <T> GetList(Func <T, bool> where, params Expression <Func <T, object> >[] navProperties) { List <T> list; using (var context = new CognizantContext()) { IQueryable <T> dbQuery = context.Set <T>(); foreach (Expression <Func <T, object> > navigationProperty in navProperties) { dbQuery = dbQuery.Include <T, object>(navigationProperty); } list = dbQuery.AsNoTracking().Where(where).AsQueryable <T>().ToList <T>(); } return(list); }
public virtual T GetSingle(Func <T, bool> where, params Expression <Func <T, object> >[] navProperties) { T item = null; using (var context = new CognizantContext()) { IQueryable <T> dbQuery = context.Set <T>(); foreach (Expression <Func <T, object> > navigationProperty in navProperties) { dbQuery = dbQuery.Include <T, object>(navigationProperty); } item = dbQuery.AsNoTracking().FirstOrDefault(where); } return(item); }
public virtual IList <T> GetAll(params Expression <Func <T, object> >[] navProperties) { List <T> list; using (var context = new CognizantContext()) { IQueryable <T> dbQuery = context.Set <T>(); if (navProperties != null) { dbQuery = navProperties.Aggregate(dbQuery, (current, include) => current.Include(include)); } foreach (Expression <Func <T, object> > navigationProperty in navProperties) { dbQuery = dbQuery.Include <T, object>(navigationProperty); } list = dbQuery.AsNoTracking().ToList <T>(); } return(list); }