Polymorphism in WCF DataContracts

Posted on 2011-10-25
Last Modified: 2012-06-27

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
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.
Question by:mentor360
    1 Comment
    LVL 18

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now