【发布时间】:2013-03-30 05:40:17
【问题描述】:
我已经在 John Papa 的出色 CodeCamper SPA 中实现了分页。这样做时,我在使用 take() 和 skip() 函数时发现了一些奇怪的东西。
考虑以下 ODATA 查询以跳过 2 条记录并取 2 条记录:
/api/Breeze/Sessions?$orderby=TimeSlotId%2CLevel%2CSpeaker%2FFirstName&$skip=2&$top=2&$select=Id&$inlinecount=allpages
这会返回:
[{"$id":"1","$type":"IB_pMnaszsw5zIeP0Q7Dam12XmjGGg[[System.Int32, mscorlib]], IB_pMnaszsw5zIeP0Q7Dam12XmjGGg_IdeaBlade","Id":3},{"$id":"2","$type":"IB_pMnaszsw5zIeP0Q7Dam12XmjGGg[[System.Int32, mscorlib]], IB_pMnaszsw5zIeP0Q7Dam12XmjGGg_IdeaBlade","Id":14}]
现在我跳过 4 条记录并取 2 条(好像移动到下一页)
/api/Breeze/Sessions?$orderby=TimeSlotId%2CLevel%2CSpeaker%2FFirstName&$skip=4&$top=2&$select=Id&$inlinecount=allpages
这会返回:
[{"$id":"1","$type":"IB_pMnaszsw5zIeP0Q7Dam12XmjGGg[[System.Int32, mscorlib]], IB_pMnaszsw5zIeP0Q7Dam12XmjGGg_IdeaBlade","Id":14},{"$id":"2","$type":"IB_pMnaszsw5zIeP0Q7Dam12XmjGGg[[System.Int32, mscorlib]], IB_pMnaszsw5zIeP0Q7Dam12XmjGGg_IdeaBlade","Id":11}]
我两次获得了 ID 为 14 的记录!我可以用任意数量的页面或记录重现此问题。
知道发生了什么吗?
[编辑]
好的,我注意到如果去掉 orderby ($orderby=TimeSlotId%2CLevel%2CSpeaker%2FFirstName&) 那么一切都很好。 orderby 怎么会出问题?
【问题讨论】:
标签: asp.net-web-api odata breeze single-page-application