是否可以查询 Odata 服务并展开子实体的子实体?
这听起来相当简单(也许我在这里错过了显而易见的事情),但我找不到解决方案。我知道我可以查询一个实体并返回一个或多个直接子实体来执行此操作:
var query = from c in Service.Clients.Expand("Addresses,Comments,PhoneNumbers")..
我希望能够做的是对 3 个级别(子级的子级)执行相同的操作,可以说“国家 -> 省 - >城市”或“品牌->家庭->模型”
我尝试扩展所有实体,但失败了
var query = from c in Service.Brands.Expand("Families,Models").. //fails,
//which even makes some sense, since Models is a Child of Family, not Brand
var query = from c in Service.Brands.Expand("Families").. //this works,
//but Family.Models is empty
有没有办法在一个查询中执行此操作,或者我是否必须将其拆分为两个单独的查询?
This sounds rather simple (and maybe I'm missing the obvious here) but I can't find a solution. I know I can query an entity and return one, or many direct child entities doing this:
var query = from c in Service.Clients.Expand("Addresses,Comments,PhoneNumbers")..
What I would like to be able to do is do the same with 3 levels (Children of child), lets say "Country->Province->City" or "Brand->Family->Model"
I tried to expand all entities, but it fails
var query = from c in Service.Brands.Expand("Families,Models").. //fails,
//which even makes some sense, since Models is a Child of Family, not Brand
var query = from c in Service.Brands.Expand("Families").. //this works,
//but Family.Models is empty
Is there a way to do this in one query, or do I have to split this in two separate queries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 ASP.NET OData v4 中,URL 约定似乎发生了变化。现在是:
您还可以在子实体中选择您想要的内容。
例如,如果您只想要品牌系列标识符:
此外,如果您只想要品牌系列型号的标识符,您可以这样做:
...等等。希望这有帮助!
In ASP.NET OData v4, the URL convention seems to have changed. It is now:
You can also select the stuff you want in sub-entities.
For example if you want just the brand family identifiers:
Furthermore, if you want only the identifiers of the brand family models, you would do that:
...and so on. Hope this helps !
以下语句应返回您要查找的内容:
这将运行以下 odata 查询:
此处是一些其他 odata 文档的链接:
The following statement should return what you are looking for:
This will run the following odata query:
Here is a link to some further odata documentation: