在RavenDB ID顺序 [英] Order by ID in RavenDB

查看:96
本文介绍了在RavenDB ID顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让乌鸦由ID字段顺序查询的结果,就好像它是整数。因此,汽车/ 2会来之前,汽车/ 11如果我做了这个查询:

  VAR汽车= session.Query< ;汽车方式>()排序依据(C => c.ID); 


解决方案

您应该不依赖于文件的ID以任何方式排序。
添加CreatedAt财产或类似的东西,并使用


Is there a way to have Raven order the results of a query by the Id field as if it was in integer. So "cars/2" would come before "cars/11" if I did this query:

var cars = session.Query<Car>().OrderBy(c => c.ID);

解决方案

You shouldn't rely on the id of the document to be sortable in any way. Add a CreatedAt property or something similar and use that

这篇关于在RavenDB ID顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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