Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var keywords = query.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).ToList();
- IQueryable<News> searchQuery;
- if (categoryId == null)
- {
- searchQuery = from n in dbEntities.News.Include("Category")
- where keywords.Any(w => n.Title.IndexOf(w, StringComparison.InvariantCultureIgnoreCase) > -1)
- select n;
- }
- else
- {
- searchQuery = from n in dbEntities.News.Include("Category")
- where n.Category.CategoryId == categoryId &&
- keywords.Any(w => n.Title.IndexOf(w, StringComparison.InvariantCultureIgnoreCase) > -1)
- select n;
- }
- resultPagesCount = (int)(Math.Ceiling(1.0 * searchQuery.Count() / NewsRepository.PAGE_SIZE));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement