【发布时间】:2016-04-11 04:41:00
【问题描述】:
我在 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 属性及其所有导航属性。
【问题讨论】:
-
请贴出
Get方法的源代码。 -
Get 使用存储库中的 mongoDB 的 FindAll 方法返回 apicintroller 中实体的 IQueryable。还具有可查询属性。你想让我更新代码还是这个信息就足够了?
-
Queryable属性已过时。您应该使用System.Web.OData.EnableQuery属性。 -
所以启用查询
-
我的意思是它已经是 EnableQuery
标签: json asp.net-web-api odata asp.net-web-api-odata