I'm using XmlSerializer for WCF service (in the case of my service there are reasons for this). But recently I've encountered the problem: I cannot find a simple way to make a reference type property required, i.e. make it's definition in XSD look like this:
<xs:element minOccurs="1" maxOccurs="1" name="Name" type="xs:string"/>
instead of this:
<xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string"/>
Here is the code for property:
[XmlElement]
public string Name { get; set; }
I know that with DataContractSerializer I can do this:
[DataMember(IsRequired = true)]
public string Name { get; set; }
and I will get the desired schema.
Any ideas how to get the functionality similar to IsRequired's with XmlSerializer attributes?
Thanks.