0
Reply

XML Schema and typed DataSet

magne.ryholt

magne.ryholt

Jun 28 2004 6:26 AM
1.4k
Using Visual Studio 2003 Consider the following simple XML Schema: As can be seen, the Child element must be within the Father element. Now I let VS make a typed DataSet out of this schema and using the following code to fill the tables: SystemModel model = new SystemModel(); SystemModel.FatherRow fatherRow = model.Father.NewFatherRow(); fatherRow.Name = "Father"; model.Father.AddFatherRow(fatherRow); SystemModel.ChildRow childRow = model.Child.NewChildRow(); childRow.Name = "Child"; // oops, "forgot to set the parent row // childRow.FatherRow = fatherRow; model.Child.AddChildRow(childRow); model.WriteXml(@"SystemModel.xml"); This produce the following XML file: This cannot be validated against the schema which was used to produce the dataset, this because I "forgot" to set the parentrow in the childrow. Is it possible to change the schema to force VS to add the statement: columnFather_Id.AllowDBNull = false; ?? Also I would like some tips of how to make the schema (so that Typed DataSet may be made on it) containing an element which contains itself (this is possible by "pure" xsd and also in a database relational model, but I don't know how to make a typed DataSet out of it) Any tips are welcome !