Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
                }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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>());
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        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>());
        }