public async Task<IList<Hop>> GetAllAsync(params string[] navigationProperties)
 {
     using (var context = new MicrobrewitContext())
     {
         IQueryable<Hop> dbQueryable = context.Set<Hop>();
         dbQueryable = navigationProperties.Aggregate(dbQueryable, (current, navigationProperty) => current.Include(navigationProperty));
         return await dbQueryable.ToListAsync();
     }
 }
 public Hop GetSingle(int id, params string[] navigationProperties)
 {
     using (var context = new MicrobrewitContext())
     {
         IQueryable<Hop> dbQueryable = context.Set<Hop>();
         dbQueryable = navigationProperties.Aggregate(dbQueryable, (current, navigationProperty) => current.Include(navigationProperty));
         return dbQueryable.SingleOrDefault(h => h.HopId == id);
     }
 }
        public BeerStyle GetSingle(int id, params string[] navigationProperties)
        {
            BeerStyle item = null;
            using (var context = new MicrobrewitContext())
            {
                IQueryable<BeerStyle> dbQuery = context.Set<BeerStyle>();

                //Apply eager loading
                foreach (string navigationProperty in navigationProperties)
                    dbQuery = dbQuery.Include<BeerStyle>(navigationProperty);

                item = dbQuery
                    .AsNoTracking() //Don't track any changes for the selected item
                    .FirstOrDefault(s => s.BeerStyleId == id); //Apply where clause
            }
            return item;
        }
        public IList<BeerStyle> GetAll(params string[] navigationProperties)
        {
            List<BeerStyle> list;
            using (var context = new MicrobrewitContext())
            {
                IQueryable<BeerStyle> dbQuery = context.Set<BeerStyle>();

                //Apply eager loading
                foreach (string navigationProperty in navigationProperties)
                    dbQuery = dbQuery.Include<BeerStyle>(navigationProperty);

                list = dbQuery
                    .AsNoTracking()
                    .ToList<BeerStyle>();
            }
            return list;
        }
        public virtual async Task<IList<BeerStyle>> GetAllAsync(int from, int size,params string[] navigationProperties)
        {
            using (var context = new MicrobrewitContext())
            {

                IQueryable<BeerStyle> dbQuery = context.Set<BeerStyle>();

                //Apply eager loading
                foreach (string navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include<BeerStyle>(navigationProperty);
                }
                return await dbQuery.ToListAsync();
            }
        }
        public virtual async Task<BeerStyle> GetSingleAsync(int id, params string[] navigationProperties)
        {
            using (var context = new MicrobrewitContext())
            {

                IQueryable<BeerStyle> dbQuery = context.Set<BeerStyle>();

                //Apply eager loading
                dbQuery = navigationProperties.Aggregate(dbQuery, (current, navigationProperty) => current.Include<BeerStyle>(navigationProperty));

                return await dbQuery.SingleOrDefaultAsync(s => s.BeerStyleId == id);
            }
        }
        public async Task<IList<Beer>> GetLastAsync(int from, int size, params string[] navigationProperties)
        {
            using (var context = new MicrobrewitContext())
            {

                IQueryable<Beer> dbQuery = context.Set<Beer>();

                //Apply eager loading
                dbQuery = navigationProperties.Aggregate(dbQuery, (current, navigationProperty) => current.Include<Beer>(navigationProperty));
                return await dbQuery.OrderByDescending(b => b.CreatedDate).Skip(from).Take(size).ToListAsync();
            }
        }