示例#1
0
文件: NewsRepo.cs 项目: tforsberg/z
        public IEnumerable<News> All(int pageIndex, int pageSize, out long totalRows)
        {
            using (var db = new MainDb())
            {
                var query = Query<News>.EQ(x=>x.Status,(int)GlobalStatus.Actived);
                var sort = SortBy<News>.Descending(x=>x.Created);

                return db.Find<News>(query, sort, pageIndex, pageSize, out totalRows);
            }
        }
示例#2
0
        public IEnumerable <News> All(int pageIndex, int pageSize, out long totalRows)
        {
            using (var db = new MainDb())
            {
                var query = Query <News> .EQ(x => x.Status, (int)GlobalStatus.Actived);

                var sort = SortBy <News> .Descending(x => x.Created);

                return(db.Find <News>(query, sort, pageIndex, pageSize, out totalRows));
            }
        }
示例#3
0
        public IEnumerable <News> QuickSearch(ObjectId catid, string kwd, int pageIndex, int pageSize,
                                              out long totalRows)
        {
            using (var db = new MainDb())
            {
                var _query =
                    Query.Or(
                        Query.Matches("title", BsonRegularExpression.Create(new Regex(kwd, RegexOptions.IgnoreCase))),
                        Query.Matches("html", BsonRegularExpression.Create(new Regex(kwd, RegexOptions.IgnoreCase))),
                        Query.In("tags", new BsonArray(kwd))
                        );

                return(db.Find <News>(_query, SortBy.Descending("crt"), pageIndex, pageSize, out totalRows));
            }
        }
示例#4
0
文件: NewsRepo.cs 项目: tforsberg/z
        public IEnumerable<News> QuickSearch(ObjectId catid, string kwd, int pageIndex, int pageSize,
                                                    out long totalRows)
        {

            using (var db = new MainDb())
            {
                var _query =
                    Query.Or(
                        Query.Matches("title", BsonRegularExpression.Create(new Regex(kwd, RegexOptions.IgnoreCase))),
                        Query.Matches("html", BsonRegularExpression.Create(new Regex(kwd, RegexOptions.IgnoreCase))),
                        Query.In("tags", new BsonArray(kwd))
                        );

                return db.Find<News>(_query, SortBy.Descending("crt"), pageIndex, pageSize, out totalRows);
            }
        }