C#ODATA,使用子实体扩展N级 [英] C# ODATA , Expand N Level with sub-entities

查看:97
本文介绍了C#ODATA,使用子实体扩展N级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要您的帮助才能实现以下目标:

I really need your help to achieve the following :

首先让我向您展示我的数据库数据模型:

First let me show you my DB data model :

1- mebs_schedule=>mebs_ingesta
2- mebs_ingesta=>mebs_ingestadetails
3- mebs_ingesta=>mebs_videoitem
4- mebs_ingesta=>mebs_channel=>mebs_channeltuning

使用下面的URI,我可以得到这棵树作为时间表的参考:

using the URI below i can get this tree for a giving Schedule reference :

mebs_schedule=>mebs_ingesta

mebs_ingesta=>mebs_ingestadetails

mebs_ingesta=>mebs_videoitem

mebs_ingesta=> mebs_channel

URI = "mebs_schedule({0})?$expand=mebs_ingesta/mebs_videoitem,mebs_ingesta/mebs_ingestadetails,mebs_ingesta/mebs_channel" 现在,我还想为每次出现的mebs_channel关联相关的mebs_channeltuning集合.

URI = "mebs_schedule({0})?$expand=mebs_ingesta/mebs_videoitem,mebs_ingesta/mebs_ingestadetails,mebs_ingesta/mebs_channel" Now i wanna get also associated mebs_channeltuning collection for each mebs_channel occurence.

我已经花了很多时间在Google上,以了解它的实现情况,但是一无所获.

i have spend time in google to find out how achive this but nothing.

一些尝试性的东西:

mebs_schedule(79)?$expand=mebs_ingesta&expand=mebs_videoitem,mebs_ingestadetails,mebs_channel&expand=mebs_channe.mebs_channeltuning

最后一个问题是,有没有办法扩展所有导入的数据模型.

Last question is there any way to expand all imported Data Model .

感谢您的帮助.

Env:VS .NET 2010/C#4.0

Env : VS .NET 2010 / C# 4.0

推荐答案

这应该很好:

URI = "mebs_schedule({0})?$expand=mebs_ingesta/mebs_videoitem,mebs_ingesta/mebs_ingestadetails,mebs_ingesta/mebs_channel/mebs_channeltuning" 

我刚刚在末尾添加了"/mebs_channeltuning".请注意,您不需要显式扩展mebs_channel,因为它的子项被扩展(在更改之后),因此将被扩展.

I just added "/mebs_channeltuning" at the end. Note that you don't need to explicitely expand the mebs_channel only since it will be expanded due to its child being expanded (after that change).

暂定解决方案有很多问题.一种是expand之前需要$符号(否则它不会被识别为查询选项).其次,服务器通常只接受一个$ expand查询选项. (并且.不是扩展名的分隔符).

The tentative solution has many issues. One is that expand needs the $ sign before it (otherwise it's not recognized as a query option). Second is that the server will usually only accept one $expand query option. (and that . is not the separator for the expansions).

无法扩展所有内容.这是有意的,因为扩展使数据可能呈指数增长,从而可能在服务器和客户端上引起问题.客户必须明确要求进行每次扩展.

There's no way to expand everything. This is intentional as expansions make the data grow potentially exponentially and thus could cause problems both on the server and on the client. The client has to explicitly ask for every expansion.

这篇关于C#ODATA,使用子实体扩展N级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆