[英]Retrieving Navigation Properties through WebGet method in WCF Data Service
friends! 朋友们! I'm having a problem with getting navigation properties in WCF Data Service in WebGet method.
我在使用WebGet方法获取WCF数据服务中的导航属性时遇到问题。
[DataContractAttribute(IsReference=true)]
and [DataMember]
attributes. [DataContractAttribute(IsReference=true)]
和[DataMember]
属性。 [ServiceContract]
attribute) and in its client I saw filled properties. [ServiceContract]
属性),并在其客户端中看到了填充的属性。 What am I doing wrong? 我究竟做错了什么? Many thanks!
非常感谢!
If the entities are not ComplexTypes, but EntityTypes (which can be retrieved from their own collection), by default they will not be populated. 如果实体不是ComplexTypes,而是EntityType(可以从它们自己的集合中检索),则默认情况下不会填充它们。 You need to use:
您需要使用:
<host>/urlForResource?$expand=Property1,Property2
If this doesn't work, check the version of the OData that you are implementing and of the WCF DataServices that you are using. 如果这不起作用,请检查您正在实现的OData和正在使用的WCF DataServices的版本。 $expand might not be implemented in WCF DataServices if you use an older version.
如果使用旧版本,则$ expand可能不会在WCF DataServices中实现。
Also, in OData services for WebApi there is an [EnableQuery] attribute which must be added to support parameters like $expand, look for the way to enable query options on WCF DataServices. 另外,在WebApi的OData服务中,必须添加[EnableQuery]属性以支持$ expand等参数,寻找在WCF DataServices上启用查询选项的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.