Search code examples
wcf-data-services

WCF Data Services and Portable Library


I'm trying to use WCF Data Services with a POCO data model contained in a Portable library. The server side has no problem to use the model, but on the client side, when the feed is materialized, I get this error :

A property with name 'Orders' on type 'PortableEntities.Customers' has kind 'Structural', but it is expected to be of kind 'Navigation'

The client seems unable to materialized a relation that is not implemented as a DataServiceCollection (a type not available to portable libraries).

Is there a way to use other ICollection type like HashSet or List?

Here is the model class in my portable library (from Northwind) :

Partial Public Class Customers
    Public Property ID As String
    Public Property CompanyName As String
    Public Property ContactName As String
    Public Property ContactTitle As String
    Public Property Address As String
    Public Property City As String
    Public Property Region As String
    Public Property PostalCode As String
    Public Property Country As String
    Public Property Phone As String
    Public Property Fax As String

    Public Overridable Property Orders As ICollection(Of Orders) = New HashSet(Of Orders)
    Public Overridable Property CustomerDemographics As ICollection(Of CustomerDemographics) = New HashSet(Of CustomerDemographics)

End Class

Solution

  • Can you share the definition for Orders class? Does Orders have a ID property or DataServiceKey attribute? If it does not, WCF Data Services will treat this as complex type rather than entity type. Adding ID property or DataServiceKey attribute might help.