开发者

Is it possible to define derivative classes that are DataContract?

Is this code can be possible in WCF ? The object base and derivativeObject are both object that will be sen开发者_C百科d to the client. I tested this and i getting an exception - but i'm not sure this is something prohibition in WCF.

[DataContract]
public class base
{
    [DataMember]
    public string Key { get; set; }

    [DataMember]
    public string ID { get; set; }
}

[DataContract]
public class derivativeObject : base
{
    [DataMember]
    public string Name { get; set; }
}


Looking to use Known Types (and the KnownTypeAttribute) perhaps?

[DataContract]
[KnownType(typeof(SalesPerson))]
public class Person
{
  [DataMember]
  public string Name { get; set; }
}

[DataContract]
public class SalesPerson : Person
{
  [DataMember]
  public double Commission { get; set; }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜