Received from WCF DataContract does not inherit the underlying DataContract property

Below is my base class WCF DataContract

  [DataContract]
    public class BaseClass
    {
       //some datamembers
    }

And here is my derived class ....

 [DataContract]
    public class DerivedClass1 : BaseClass
    {
       [DataMember]
       public string ProductName{get;set;}
    }

Due to some change in requirements, I am adding another derived type that also has the same ProductName property.

So, the code structure is now ...

 [DataContract]
        public class BaseClass
        {
           //some datamembers
           [DataMember]
           public string ProductName{get;set;}
        }

[DataContract]
        public class DerivedClass1 : BaseClass
        {
           //[DataMember]
           //public string ProductName{get;set;}  property moved to base class
        }

[DataContract]
            public class DerivedClass2 : BaseClass
            {
               //some datamembers specific to DerivedClass2
            }

so I moved the "ProductName" property to the base class. But now, when an existing datacontract is called from a client that returns a list of Derivedclass1 to me, I do not see productName in response. One way or another, my DerivedClass1 does not enter the productName property from the database. What could be the reason? Can I make mistakes when writing code?

+3
source share
2 answers

[KnownType (typeof (BaseClass))] , .

0

, !

Base type

SubClass SychRequests

Child class

Intellisense.

Working

, . ProductName , , .

0

All Articles