Esempio n. 1
0
        public IEnumerable <T> GetAll(Func <IQueryable <T>, IOrderedQueryable <T> > orderBy = null,
                                      Expression <Func <T, bool> > filter = null,
                                      Expression <Func <T, IEnumerable <T> > > includeOther = null,
                                      string includeProperties = "")
        {
            IQueryable <T> query = db.Set <T>();



            if (filter != null)
            {
                query = query.Where(filter);
            }

            foreach (var includeProperty in includeProperties.Split
                         (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                query = query.Include(includeProperty);
            }
            if (includeOther != null)
            {
                query = query.Include(includeOther);
            }

            if (orderBy != null)
            {
                query = orderBy(query);
            }

            return(query);
        }
 public GenericRepository(BlogContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }