Retrieving Navigation Properties through WebGet method in WCF Data Service

142 views Asked by At

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!

1

There are 1 answers

0
Cosmin Vană On

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.