ODATA.NEXTLINK的ODATA标准是1:n $展开查询的情况?
我们可以在服务器驱动的Paging中看到 odata.nextlink 标准,用于正常查询在这里。但是,在1:n $ Expand 查询 $展开文档。
有人可以确认1:n $ Expand 查询的ODATA标准吗?
示例: 如果我们对单个 account 有多个 Account_tasks ,则结果应该看起来像:
GET [Organization URI]/api/data/v9.1/accounts?$top=1&$expand=Account_Tasks($select=subject)
option-1 :其中显示数据在列表中inline inline inline toll Till中如果数据计数超过页面尺度,则显示页面尺寸和 odata.nextlink 。因此,odata.nextlink将显示下一组结果。 (类似于标准分页在这里。
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"@odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account_tasks here. No odata.nextLink if data count < page-size.
]
}
]
}
option-2 :我们将显示空的内联结果,并向实际数据提供 odata.nextlink 。
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [],
// Empty list shown above and URL given below will show the full results.
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
option-3 :在列表中显示数据的位置,并且每次显示 odata.nextlink (即使数据计数小于页面尺寸) 。因此, odata.nextlink 将显示完整的扩展结果,包括内联结果。
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"@odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account tasks here
],
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
提前致谢。
We can see the odata.nextlink standard in the server driven paging for normal queries here. But there is no odata.nextlink standard mentioned in case of 1:N $expand queries in $expand docs.
Can someone please confirm OData standard for 1:N $expand queries please?
Example:
If we have multiple account_tasks for a single account, how the result should look like:
GET [Organization URI]/api/data/v9.1/accounts?$top=1&$expand=Account_Tasks($select=subject)
Option-1: Where data is shown in list inline till the page-size, and odata.nextLink is shown if data count exceeds the page-size. So, odata.nextLink will show the next set of results. (Similar to standard pagination here.)
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"@odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account_tasks here. No odata.nextLink if data count < page-size.
]
}
]
}
Option-2: We'll show empty results inline and provide an odata.nextLink to actual data.
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [],
// Empty list shown above and URL given below will show the full results.
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
Option-3: Where data is shown in list till page-size, and odata.nextLink is shown every time (even if data count is smaller than the page-size). So, the odata.nextLink will show the full expand results including inline results.
{
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"@odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"@odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account tasks here
],
"[email protected]": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好问题 - 嵌套结果的分页常常被误解。
嵌套结果单独分配,因此,在特定帐户的嵌套account_tasks超过了严重定义的阈值的位置,包括该阈值的帐户_task以及一个nextLink以检索该帐户的其他帐户_task。我相信这是您的选项1。
请注意,由于阈值是服务器定义的,因此阈值为0也有效,并且仅包含nested Account_tasks的NextLink。但是,每个帐户仍将具有不同的NextLink,然后遵循NextLink将仅返回返回NextLink的帐户的那些帐户。
这有意义吗?
Good question -- paging of nested results is often misunderstood.
Nested results are paged individually, so where the nested account_tasks for a particular account exceeds a sever-defined threshold, the account_tasks up to that threshold are included, along with a nextlink to retrieve the additional account_tasks for that account. Which, I believe, is your Option 1.
Note that, since the threshold is server-defined, it is also valid to have a threshold of 0, and only include a nextlink for the nested account_tasks. However, each account will still have a different nextlink, and following that nextlink will return only those account_tasks for the account in which the nextlink was returned.
Does that make sense?