Heritage in DataContracts

Topics: Service Factory Modeling Edition Forum
Jun 6, 2009 at 5:17 AM

I can't seem to find the way to model a heritage in my DataContracts. I have a class with many differnt implementations, thus, I created child classes from the parent. How can I model that behaior in WSSF?

In my current code I have an abstract class wih the [KnownType(typeof(SubClass))] attribute. Can I achieve the same with the modeler?

Developer
Jun 6, 2009 at 12:43 PM

The DataContract model has a limited way of achieving inheritance and is basically restricted to collections of types with the collection elements.

If you want to build a more complex inheritance hierarchy you may ust the contract first approach where you first create the type schema and then you may use the ImportWSDL extension (you can find it in the WSSF Contrib site) to create your ServiceContract and have your operations reference your shcema. That will later generate all the Contract classes (SC and DC).

As a side comment, usually data contracts represent simple DTO (data transfer object pattern) so you can expose the basic flat structure for collecting data transfer information and build your rich business structures beyond your service implementation layer.