简体   繁体   English

将System.Linq.Dynamic与MongoDB集合一起使用时顺序错误

[英]Wrong order when using System.Linq.Dynamic with MongoDB collection

I use System.Linq.Dynamic to order a MongoDB collection. 我使用System.Linq.Dynamic来订购MongoDB集合。

mongoCollection.AsQueryable().OrderBy("Name ASC");

But the lowercase names gets ordered after the capital cased names, so the items are returned something like this. 但是小写字母的名称在大写字母的名称之后进行排序,因此返回的项目如下所示。

  • Ape
  • Cat
  • Dog
  • alligator 鳄鱼
  • ant 蚂蚁
  • beetle 甲虫

I rather expected this: 我宁愿这样:

  • alligator 鳄鱼
  • ant 蚂蚁
  • Ape
  • beetle 甲虫
  • Cat
  • Dog

Is there a way to get the correct order? 有没有办法获得正确的订单?

你有没有尝试过

mongoCollection.AsQueryable().ToList().OrderBy(c=>c.Name.ToLower());

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

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