Пример #1
0
        public IEnumerable<BOC.Entities.News> GetNewsByHeadLine(NewsTypeQry newsTypeQry)
        {
            var select = _BOCWebDBContext.News.Where(e => e.IsTopNews == true && e.IsPushOut == true);
            if (!string.IsNullOrEmpty(newsTypeQry.languagecode))
            {
                select = select.Where(e => e.NewsLanguageCode == newsTypeQry.languagecode);
            }
            if (!string.IsNullOrEmpty(newsTypeQry.country))
            {
                select = select.Where(e => e.Countury == newsTypeQry.country);
            }
            if (!string.IsNullOrEmpty(newsTypeQry.keyword))
            {
                select = select.Where(e => e.NewsTitle.Contains(newsTypeQry.keyword) || e.KeyWords.Contains(newsTypeQry.keyword) || e.NewsSummary.Contains(newsTypeQry.keyword));
            }

            var lNews = select.OrderByDescending(e => e.NewsDateTime).ThenByDescending(e => e.NewsID).Skip((newsTypeQry.page - 1) * newsTypeQry.pagesize).Take(newsTypeQry.pagesize).ToList();
            //var lNews = _BOCWebDBContext.News.Where(e => e.IsTopNews == true && e.NewsLanguageCode == newsTypeQry.languagecode).OrderBy(e => e.NewsDateTime).Skip(newsTypeQry.page * newsTypeQry.pagesize).Take(newsTypeQry.pagesize);
            return lNews;
        }
Пример #2
0
        public int GetNewsCountByType(NewsTypeQry newsTypeQry)
        {
            var select = _BOCWebDBContext.News.Where(e => e.IsPushOut == true);
            if (!string.IsNullOrEmpty(newsTypeQry.languagecode))
            {
                select = select.Where(e => e.NewsLanguageCode == newsTypeQry.languagecode);
            }
            if (!string.IsNullOrEmpty(newsTypeQry.type))
            {
                select = select.Where(e => e.Type == newsTypeQry.type);
            }
            if (!string.IsNullOrEmpty(newsTypeQry.country))
            {
                select = select.Where(e => e.Countury == newsTypeQry.country);
            }
            if (!string.IsNullOrEmpty(newsTypeQry.keyword))
            {
                select = select.Where(e => e.NewsTitle.Contains(newsTypeQry.keyword) || e.KeyWords.Contains(newsTypeQry.keyword) || e.NewsSummary.Contains(newsTypeQry.keyword));
            }

            int count = select.Count();
            return count;
        }