Пример #1
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);
            }
        }
Пример #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
        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);
            }
        }