public virtual IList <T> GetList <T>(Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { IList <T> list; using (var db = new DbCtx(_dbContextName)) { list = GetList <T>(db, where, navigationProperties); } return(list); }
public virtual T Get <T>(Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { T item; using (var db = new DbCtx(_dbContextName)) { item = Get <T>(db, where, navigationProperties); } return(item); }
public virtual IList <T> Search <T>(string term, params Expression <Func <T, object> >[] navigationProperties) where T : class { IList <T> list; using (var db = new DbCtx(_dbContextName)) { var objectSet = ((IObjectContextAdapter)db).ObjectContext.CreateObjectSet <T>(); foreach (Expression <Func <T, object> > navigationProperty in navigationProperties) { objectSet = objectSet.Include <T, object>(navigationProperty); }
public virtual PaginatedResult <T> GetPaginated <T>(int page, int limit, Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { PaginatedResult <T> result = new PaginatedResult <T>(); using (var db = new DbCtx(_dbContextName)) { result.Total = Count <T>(db, where, navigationProperties); result.Items = GetPaginated <T>(db, page, limit, where, navigationProperties); result.Page = page; result.Limit = limit; } return(result); }
private IList <T> GetList <T>(DbCtx db, Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { IQueryable <T> query = db.GetQuery <T>(where, navigationProperties); return(query.ToList <T>()); }
private T Get <T>(DbCtx db, Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { IQueryable <T> query = db.GetQuery <T>(where, navigationProperties); return(query.FirstOrDefault()); }
private IList <T> GetPaginated <T>(DbCtx db, int page, int limit, Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties) where T : class { IQueryable <T> query = db.GetQuery <T>(where, navigationProperties); return(query.Skip(page * limit).Take(limit).ToList <T>()); }