public long GetApartmentsCount(GetApartmentsParams param) { var query = GetApartmentQuery(param); return query.Count(); }
private IQueryable<Apartment> GetApartmentQuery(GetApartmentsParams param) { return context.Apartments.Where(m => m.Published == true) .Include(m => m.Profile) .Include(m => m.ApartmentOptions) .Include(m => m.Type) .Include(m => m.DefaultPhoto.Links) .Include(m => m.ApartmentPhotos.Select(k => k.Links)) .OrderByDescending(m => m.UpdateDate) .AsQueryable(); }
public List<Apartment> GetApartments(GetApartmentsParams param) { var query = GetApartmentQuery(param); if (param.Take != 0) { query = query.Skip(param.Skip).Take(param.Take); } return query .ToList(); }