C# Class to XSD

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
How do I create a C# class to enforce an element to be unique in the generated xsd (via xsd.exe)?
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
In below class, how do I enforce "ID" to be unique. I know XSD ignores some attributes and hence does not support binding. Is there a workaround?
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
public class Customer<br/>
{<br/>
public int ID { get; set; }
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
[XmlElement(IsNullable = true)]
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
public string Name {get; set;}<br/>
public DateTime? IssueDate {get; set;}<br/>
}
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px
The resulting xsd:
<span style="white-space:pre <xsd:complexType name="Customer <br/>
<xsd:sequence><br/>
<xsd:element minOccurs="1" maxOccurs="1" name="<span style="color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; font-size:13px; line-height:18.200000762939453px; background-color:#f0f3f4 ID "
type="xsd:int"/><br/>
<xsd:element minOccurs="1" maxOccurs="1" name="<span style="color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; font-size:13px; line-height:18.200000762939453px; background-color:#f0f3f4 Name "
type="xsd:string"/><br/>
<xsd:element minOccurs="1" maxOccurs="1" name="<span style="color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; font-size:13px; line-height:18.200000762939453px; background-color:#f0f3f4 DateTime"
type="xsd:dateTime"/>
</xsd:sequence>
</xsd:complexType>
<br/>

<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px

<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif; line-height:18.200000762939453px


View the full article
 
Back
Top