大家好,我datacontract有繼承,但消費服務時的最後一個成員是不可訪問:DataContract繼承不知道類型
namespace Services.SearchService
{
[DataContract]
[KnownType(typeof(LabellingSearch))]
public class SearchResult
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string Title { get; set; }
[DataMember]
public DateTime Modified { get; set; }
}
/// <summary>
/// Specialist Search Result for Labelling Content Data
/// </summary>
[DataContract]
[KnownType(typeof(Labelling))]
public class LabellingSearch : SearchResult
{
[DataMember]
public string Region { get; set; }
[DataMember]
public string Country { get; set; }
[DataMember]
public string LabelSummary { get; set; }
}
/// <summary>
/// Full Labelling Content Data
/// </summary>
[DataContract]
public class Labelling : LabellingSearch
{
public string Content { get; set; }
}
}
所以在消費類我可以訪問類型「標籤」,但我可以」無法獲取其「內容」屬性。
衛生署! (捂臉) –