如何指定订购或使用排序MongoDB的C#的驱动程序? [英] How to specify an Order or Sort using the C# driver for MongoDB?

查看:169
本文介绍了如何指定订购或使用排序MongoDB的C#的驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何通过告诉C#驱动程序的排序顺序是排序文件服务器端的集合,但它不似乎支持那个结构。

I'm trying to figure out how to sort a collection of documents server side by telling the C# driver what the sort order is, but it appears not to support that construct yet.

是否有可能做到这一点任何其他方式?

Is it possible to do this any other way?

推荐答案

您也可以做到这一点上使用SetSortOrder方法该MongoCursor类:

You can also do it using the SetSortOrder method on the MongoCursor class:

db["collection"].Find().SetSortOrder(SortBy.Ascending("SortByMe"));

这篇关于如何指定订购或使用排序MongoDB的C#的驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆