简体   繁体   中英

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.

  1. I turned off ProxyCreationEnabled and LazyLoadingEnabled
  2. I have [DataContractAttribute(IsReference=true)] and [DataMember] attributes.
  3. I see filled properties on service side, but I don't see their on client side.
  4. I created usual WCF service (based on [ServiceContract] attribute) and in its client I saw filled properties.

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. 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. $expand might not be implemented in WCF DataServices if you use an older version.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM