When using xsd.exe, which File option should I choose and why?
I have received a xsd file from a third party vendor for some XML files we currently receive. In order to process开发者_如何学编程 the files, I have used xsd.exe
to generate my classes. I see that there are two command line options available, namely:
/c[lasses]
and/d[ataset]
My question is noobish at best, which option should I choose and why?
PS:
I have tried both, however, at present, the /d
option results in some error regarding nested tables. The /c
option does work for me although it requires a lot of data-mapping to my domain objects.
Use /c
. A DataSet
is an in-memory representation of a relational database. Not all XML Schema files map to a relational database model. The error message you received was no doubt because your schemas cannot map to the relational model.
/c
will produce classes that can be loaded from or saved to an XML file by using the XmlSerializer
.
I'd advise choosing the 'c' option as datasets are evil. Pure evil.
I think /d will give you a dataset to work with the data of the XML. The /c will generate the classes you need to work with the data.
Now, that's your choice, you'll need data-mapping to your domain objects for both options, imho.
精彩评论