I am using XSD\'s to define my DTO types in C#. I am using XSD.exe to gen the classes from the XSD\'s.
I have a Common.xsd that defines an Address type and I want to use
You can use XSD.exe
with multiple file arguments:
xsd .\XSD\Common.xsd .\XSD\Employee.xsd .\XSD\Company.xsd /c /o:. /n:"DomainModel"
You basically want to split out the common types into a common assembly which is references by your other types. You have two options:
If you fancy option 2 above then here is the general process:
However, this approach is based on svcutil using the DataContractSerializer to do the work, as the /r flag is not available to XmlSerializer. And this will only work if the your schemas adhere to the rather strict DCS rules (can be found here: http://msdn.microsoft.com/en-us/library/ms733112.aspx).
If these rules are not adhered to then svcutil will fall back to using XmlSerializer which does not support /r flag.