[英]WCF: “IsRequired” property for DataMember with “IsReference” property for DataContract
Why does WCF does not allow to set the "IsRequired" property for DataMembers when I set the "IsReference" property for the DataMember's DataContract? 当我为DataMember的DataContract设置“IsReference”属性时,为什么WCF不允许为DataMembers设置“IsRequired”属性? And is there a way to solve this problem?
有没有办法解决这个问题?
[DataContract(IsReference = true)]
public class MyClass
{
private DateTime date;
[DataMember (IsRequired = true)]
public DateTime Date
{
get { return date; }
set { date = value; }
}
}
This code will create an error because "IsReference" and "IsRequired" are set. 此代码将创建错误,因为已设置“IsReference”和“IsRequired”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.