/// <summary> /// mongodb分页查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sortQuery"></param> /// <param name="query"></param> public void GetPaging<T>(Dictionary<string, string> sortQuery, Expression<Func<T,bool>> query) { if (sortQuery.Count < 0) { return; } IMongoClient mongoClient = new MongoClient(""); IMongoDatabase mongoDatabase = mongoClient.GetDatabase(""); var sort = Builders<T>.Sort; SortDefinition<T> sortimp = null; foreach (var item in sortQuery) { if (item.Value == "d") { sortimp = sort.Descending(item.Key); } else { sortimp = sort.Ascending(item.Key); } } mongoDatabase.GetCollection<T>(typeof(T).Name).Find<T>(query).Sort(sortimp)?.Limit(1).Skip(1); }