Support navigation properties on complex types
WCF DS recently (5.0?) introduced the awesome feature of properties being collections of complex objects. This makes great sense for e.g. orders/orderlines and persons/addresses, since each orderline/address is owned by its parent (order/person) and does not need to be an entity. For some backends this enables great performance increase in some scenarios.
The typical theoretical example of using complex types is an Address property of some entity. In the real world an address typically contains a city and/or a country. Although the address is unique, the city and/or county probably would be shared between several entities. Thus we would like to model the city and the country as entities rather than complex types.
But since we are not allowed to have navigation properties on complex types, we can not model the address as having a city and/or country. And then the use case of order/orderlines and persons/addresses fails...
For simple complex properties (not collections) a common workaround would probably be putting the entity references on the owning entity instead of in the complex property. For collections of complex objects this is not an option.
And since complex properties should be nothing more than imposing structure on the entity ("grouping properties"), we should be able to to use the same toolset when constructing the complex types as when constructing the entity types.
A wild guess is that this limitation comes from Entity Framework and relational databases where the complex type is typically mapped to a table and the navigation property would create a foreign key between the complex type table and the referenced entity. When building custom providers, we are not limited to relational databases though. Just guessing...
What do you think?
As Ralf says, “This is part of OData 4.0, see http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part3-csdl.html#_Toc360208810”;
This is part of OData 4.0, see http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part3-csdl.html#_Toc360208810