XML 比单层更深的 WCF Datacontract

WCF Datacontract for XML deeper that a single layer

抱歉,一个非常简单的问题,我似乎找不到答案。我正在尝试为 WCF 服务编写数据合同以接收以下 xml:

<?xml version="1.0"?>
<CachedAwiData QReference="3" QAttempt="0" QReservation="{D6154D1C-6D42-4AA5-9FAC-217B2F9FE096}">
                <CachedAwiDataRecord>
                                <CustRef><![CDATA[1]]></CustRef>
                                <Details><![CDATA[Hello World]]></Details>
                                <PrefDay><![CDATA[Monday]]></PrefDay>
                                <PrefTime><![CDATA[8.00am - 9.00am]]></PrefTime>
                                <Priority><![CDATA[Urgent]]></Priority>
                                <Trade><![CDATA[Plasterer]]></Trade>
                </CachedAwiDataRecord>
</CachedAwiData> 

到目前为止,我已经尝试了一些事情并得到了:

[DataContract(Namespace = "")]
public class CachedAwiData
{

}

[DataContract(Namespace = "")]
public class CachedAwiDataRecord : CachedAwiData
{
    [DataMember]
    public string CustRef { get; set; }
}

我得到的回复似乎是 CustRef 的空值:

<ResponseData xmlns="http://schemas.datacontract.org/2004/07/RestService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><CustRef i:nil="true" /></ResponseData>

我假设它与我的 DataContract 有关,但也许我在这里遗漏了一些东西。非常感谢任何线索,或者我最好回到 XML 序列化程序?

我觉得继承不对。我不怎么使用 DataContracts,但我认为你需要类似

的东西

    [DataContract(Namespace = "")]
    public class CachedAwiData
    {
        [DataMember]
        public CachedAwiDataRecord DataRecord;
    }

    [DataContract(Namespace = "")]
    public class CachedAwiDataRecord 
    {
        [DataMember]
        public string CustRef { get; set; }
    }