0

我在 web api 中使用 v4 的 oData。

我的 get all 调用正确地返回了整个集合(总共 3 个对象)。

http://localhost:9910/api/CommandsRest

在此处输入图像描述

但试图只选择 StoreCommand 给了我 3 个空白对象

http://localhost:9910/api/CommandsRest?$select=StoreCommand

试图扩展 StoreCommand 给了我 StoreCommand 但没有给我它的导航属性

http://localhost:9910/api/CommandsRest?$expand=StoreCommand

我只想要主对象的 StoreCommand 属性及其所有导航属性。

4

1 回答 1

1

试试/CommandsRest?$select=StoreCommand&$expand=StoreCommand($expand=DictionaryVariables)。这将为您提供每个 StoreCommand 与 DictionaryVariables 属性展开内联。

如果您想要StoreCommand 的所有导航属性,则必须在嵌套的 expand 子句中明确列出它们。例如,$expand=DictionaryVariables,DictionaryNestedSplitVariables,DictionaryMultipleVariables,TabularVariables

请注意,我使用内存数据而不是 MongoDB 测试了这些 URI。

于 2016-01-07T00:25:45.740 回答