我想将字符串DataMember设置为必需,我已设置" IsRequired = true"但它在XML请求中显示为可选。
[MessageContract(WrapperName = "tourinforequest")]
public class TourInfoRequest
{
public TourInfoRequest()
{
Request = new TourInfoRequestRequestData();
}
[MessageBodyMember]
public TourInfoRequestRequestData Request;
}
public class TourInfoRequestRequestData : BaseRequest
{
[DataMember(Order = 1, IsRequired = true ), XmlElement(ElementName = "tourcode")]
public string TourCode { get; set; }
[DataMember(Order = 2, IsRequired = true), XmlElement(ElementName = "depdate")]
public DateTime DepartureDate { get; set; }
}