简体   繁体   English

没有linq的mongoDB数组排序

[英]mongoDB array sorting without linq

I am C# mongoDB driver. 我是C#mongoDB驱动程序。 Below is sample data structure. 下面是示例数据结构。 I would like to know what is best way to get the sorted scores without using LINQ or generics. 我想知道什么是不使用LINQ或泛型而获得排序分数的最佳方法。

db.students
{ name: 'Jane',
  scores: [
              { course: 'math', marks: '35'},
              { course: 'biology', marks: '50'},
              { course: 'english', marks: '40'}
          ]
}

Use the aggregate framework of mongoDB and use the $sort and return the document. 使用mongoDB的聚合框架,并使用$ sort并返回文档。 http://docs.mongodb.org/manual/reference/operator/aggregation/sort/ http://docs.mongodb.org/manual/reference/operator/aggregation/sort/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM