1
Vote

DataContract inheritance out of the box

description

As .Net developer, I believe it would be an excellent characteristic of WCF behavior to support DataContract inheritance out of the box.

Currently I'm able to overcome this issue by doing one of two things:
  1. Decorate the base DataContract classes with [KnownType] attribute for each child DataContract class (which is not elegant and violates class inheritance principle)
  2. Use the generic resolver: http://msdn.microsoft.com/en-us/magazine/gg598929.aspx
These two solutions work but none of them is good enough to avoid writting custom code just to allow using of simple DataContracts, besides the second approach, which is far more flexible, finds its handicap when related with WCF Routing or WF Services where I'm not able to apply the generic resolver to overcome this issue.

I believe this should be an out of the box functionality of WCF so it would allow every WCF possible scenario to understand the inheritance without any extra code.

comments

digitalpacman wrote Mar 16, 2012 at 2:01 PM

They arn't exactly supporting this anymore... incase you haven't noticed they have moved to beta and are part of .net 4.5. Check the home page.

digitalpacman wrote Mar 16, 2012 at 2:01 PM

This is not a site for WCF... its for WebApi.

digitalpacman wrote Mar 16, 2012 at 2:03 PM

Nevermind... just noticed that you have no component selected. I wonder why you can't choose your component anymore.