WCF: IsRequired property for DataMember with IsReference property for DataContract

Why doesn't WCF allow the IsRequired property to be set for DataMembers when I set the IsReference property for DataMember DataContract? 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 generate an error because "IsReference" and "IsRequired" are set.

+4
source share
1 answer

There is an explanation of the behavior you get here

I am not sure how to solve this problem.

+1
source

Source: https://habr.com/ru/post/1299942/


All Articles