衍生实体中的Nevigation属性 - VS 2012 [英] Nevigation Properties in Derived Entities - VS 2012

查看:132
本文介绍了衍生实体中的Nevigation属性 - VS 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 8的VS 2012中测试我的WCF数据服务,来自我的浏览器。具体来说,我正在测试与派生实体关联的导航属性,导航属性似乎不起作用。这是oData  url请求;



HTTP://本地主机:3816 / SentagonDataService.svc /片(4L)$滤波器= ISOF('Sentagon.Web.Data。 Group')/ GroupOwner



'Elements'是根实体集


'Sentagon.Web.Data.Group'是来自'Element'的派生实体


'GroupOwner'是'Group'的导航属性


此查询的结果是"HTTP 400 - 无法找到网页",但我应该将"元素"作为"组"实体的所有者。


我想我应该将'http:// localhost:3816 / SentagonDataService.svc / Elements(4L)?$ filter = isof('Sentagon.Web.Data.Group')'投射到'Sentagon.Web.Data.Group '在应用'GroupOwner'导航属性之前,但我不确定是否支持演员表。

解决方案


当我们在派生类型上添加对NavigationProperties的支持时,我们还添加了一些新功能供人们查询这些通过Uri。您可以像这样写一个uri而不是使用IsOf


   
http:// localhost:3816 / SentagonDataService.svc / Elements(4L)/
Sentagon .Web.Data.Group / GroupOwner


本质上,类型名称用作段。您也可以在其他位置使用此类型细分。 您编写的过滤器查询无效。它应该失败。


如果你想进一步了解派生类型的属性以及如何构建Uri,请看下面的uri


http://www.odata。 org / blog / 2010/8/6 / enhance-odata-support-for-querying-derived-types --- revisited


谢谢,


Chris Robinson - SDET OData团队


I am testing my WCF data service, in VS 2012 on windows 8, from my browser. Specifically I am testing the navigation properties associated with the derived entities and the navigation properties do not seem to work. Here is the oData url request;

http://localhost:3816/SentagonDataService.svc/Elements(4L)?$filter=isof('Sentagon.Web.Data.Group')/GroupOwner

The 'Elements' is the root entity set

The 'Sentagon.Web.Data.Group' is a derived entity from the 'Element'

The 'GroupOwner' is a navigation property of the 'Group'

Result of this query is 'HTTP 400 - The webpage cannot be found' although I should be getting an 'Element' as the owner of the 'Group' entity.

I think I should cast the 'http://localhost:3816/SentagonDataService.svc/Elements(4L)?$filter=isof('Sentagon.Web.Data.Group')' to the 'Sentagon.Web.Data.Group' prior to applying the 'GroupOwner' navigation property but I am not sure if the cast is even supported.

解决方案

When we added support for NavigationProperties on derived types we also added some new abilities for people to query these via the Uri. Instead of using IsOf, you can write a uri like this

    http://localhost:3816/SentagonDataService.svc/Elements(4L)/Sentagon.Web.Data.Group/GroupOwner

Essentially the type name is used as a segment. You can use this Type segment in other places as well. The filter query you wrote is invalid. It should fail.

If you want to know more about the properties on Derived types and how to build Uri's take a look at the following uri

http://www.odata.org/blog/2010/8/6/enhancing-odata-support-for-querying-derived-types---revisited

Thanks,

Chris Robinson - SDET OData Team


这篇关于衍生实体中的Nevigation属性 - VS 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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