public List <Property> SelectMultipleWithoutSearch(int skip, int take) { SlickCMSDataContext dc = SlickCMSDataContext.Create(); var query = ( from p in dc.Properties select p ); //apply sort by criteria PropertySearch ps = new PropertySearch().Get(); if (Validation.IsNull(ps.SortBy, "").ToString() != "") { switch (ps.SortBy) { case "PriceAsc": query = query.OrderBy(p => p.Price); break; case "PriceDesc": query = query.OrderByDescending(p => p.Price); break; case "BedroomsAsc": query = query.OrderBy(p => p.Bedrooms); break; case "BedroomsDesc": query = query.OrderByDescending(p => p.Bedrooms); break; default: //not implemented, so stick with standard sorting: query = query.OrderByDescending(p => p.DateModified); break; } } else { query = query.OrderByDescending(p => p.DateModified); } return(query.Skip(skip).Take(take).ToList()); }
public List <Property> SelectMultiple(int skip, int take) { SlickCMSDataContext dc = SlickCMSDataContext.Create(); var query = ( from p in dc.Properties select p ); //apply search criteria PropertySearch ps = new PropertySearch().Get(); if (Validation.IsNull(ps.SaleType, "").ToString() != "") { query = query.Where(p => p.SaleType == ps.SaleType); } if (Validation.IsNull(ps.PropertyType, "").ToString() != "") { query = query.Where(p => p.PropertyType == ps.PropertyType); } if (Validation.IsNull(ps.PriceFrom, "0").ToString() != "0") { query = query.Where(p => p.Price >= ps.PriceFrom); } if (Validation.IsNull(ps.PriceTo, "0").ToString() != "0") { query = query.Where(p => p.Price <= ps.PriceTo); } if (Validation.IsNull(ps.Bedrooms, "0").ToString() != "0") { query = query.Where(p => p.Bedrooms >= ps.Bedrooms); } if (Validation.IsNull(ps.Bathrooms, "0").ToString() != "0") { query = query.Where(p => p.Bathrooms >= ps.Bathrooms); } if (Validation.IsNull(ps.Furnishings, "").ToString() != "") { query = query.Where(p => p.Furnishings == ps.Furnishings); } if (Validation.IsNull(ps.SortBy, "").ToString() != "") { switch (ps.SortBy) { case "PriceAsc": query = query.OrderBy(p => p.Price); break; case "PriceDesc": query = query.OrderByDescending(p => p.Price); break; case "BedroomsAsc": query = query.OrderBy(p => p.Bedrooms); break; case "BedroomsDesc": query = query.OrderByDescending(p => p.Bedrooms); break; default: //not implemented, so stick with standard sorting: query = query.OrderByDescending(p => p.DateModified); break; } } else { query = query.OrderByDescending(p => p.DateModified); } return(query.Skip(skip).Take(take).ToList()); }