Add restrictions to WCF in method/data member

Viewed 6891

I'm new to WCF and I try to add restriction to data member.

For exmple in this method:

[DataMember]
    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }

I want to set max and min length. I know how to add the restriction to the XML code

 <xs:restriction base="xs:string">
  <xs:minLength value="2"/>
  <xs:maxLength value="10"/>
</xs:restriction>

but is there a way to add a restriction straight from the code?

2 Answers
Related