我正在使用 xsd2code 而我的 xsd 有这个
<xs:element name="TransactionRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Records">
<xs:complexType>
<xs:sequence>
<xs:element name="RequestRecord" minOccurs="1" maxOccurs="5">
<xs:complexType>
<xs:sequence>
<xs:element name="Program" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Key" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Data" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
我想要实现的是这个
[DataContractAttribute(Name = "TransactionRequest")]
public partial class TransactionRequest
{
[DataMember(IsRequired = true, EmitDefaultValue = false)]
public RecordsType Records { get; set; }
[CollectionDataContractAttribute(Name = "TransactionRequest.RecordsType", ItemName = "RequestRecord")]
public class RecordsType : List<RequestRecord> { }
}
[DataContractAttribute(Name = "RequestRecord")]
public partial class RequestRecord
{
[DataMemberAttribute()]
public string Program { get; set; }
[DataMemberAttribute()]
public string Key { get; set; }
[DataMemberAttribute()]
public string Data { get; set; }
}
但我得到的是这个
[DataContractAttribute(Name = "TransactionRequest")]
public partial class TransactionRequest
{
[XmlArrayItemAttribute("RequestRecord", IsNullable = false)]
[DataMemberAttribute()]
public List<TransactionRequestRequestRecord> Records { get; set; }
public TransactionRequest()
{
this.Records = new List<TransactionRequestRequestRecord>();
}
}
[DataContractAttribute(Name = "TransactionRequestRequestRecord")]
public partial class TransactionRequestRequestRecord
{
[DataMemberAttribute()]
public string Program { get; set; }
[DataMemberAttribute()]
public string Key { get; set; }
[DataMemberAttribute()]
public string Data { get; set; }
}
我需要对 xsd 进行哪些更改才能获得我想要的东西?