[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 896
  • Last Modified:

Polymorphism in WCF DataContracts

Hi,

I would like to know if it's possible to use polymorphism in DataContract classes for a WCF service.

lets say i have a method GetAll
[OperationContract]
IEnumerable<BasicDTO> GetAll();

Open in new window

in my service. This method returns a collection of BasicDTO. This DTO has a code and a name properties.

Also I have several classes extending BasicDTO. Lets call one ComplexDTO a class that also has 2 more properties.(creatonDate and creationUser). Both properties with the [DataMember] attribute.

Is it possible to return a IEnumerable<ComplexDTO> in the GetAll Implementation? Will the extra properties of ComplexDTO arrive to the client?

Thank You.
0
mentor360
Asked:
mentor360
1 Solution

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now