public IList <Vehicle> GetAll(string term, string order, int skip, int take) { term = term?.ToLower() ?? ""; return(_dbContext.Set <Vehicle>().Include(x => x.Brand).Where(x => x.Brand.Name.Contains(term) || x.Model.Contains(term)) .OrderBy(order) .Skip(skip) .Take(take) .ToList()); }
public void Seed() { var listBrands = new List <Brand> { new Brand { Name = "Fiat" }, new Brand { Name = "Chevrolet" }, new Brand { Name = "Wolkswagem" }, new Brand { Name = "Kia" }, new Brand { Name = "Renault" }, new Brand { Name = "Toyota" } }; if (_dbContext.Set <Brand>().Any()) { return; } _dbContext.AddRange(listBrands); _dbContext.SaveChanges(); }
public IList <T> GetAll(params Expression <Func <T, object> >[] includes) { var query = _dbContext.Set <T>().AsNoTracking(); if (includes.Length <= 0) { return(query.ToList()); } query = includes.Aggregate(query, (current, inc) => current.Include(inc)); return(query.ToList()); }