Search code examples
c#xmlserializationdatasetxelement

DataSet.GetXmlSchema() do not returns nillable attribute


I'm serializing DataSet using GetXmlSchema() and GetXml() methods (code below), but in schema and xmlData there is no xsi:nil or nillable attributes for columns which are nullable. When deserializing how could I know that column is nullable?

XElement schema = XElement.Parse(dataSet.GetXmlSchema());
XElement xmlData = XElement.Parse(dataSet.GetXml());

Is there any way to get those attributes in serialized xml?


Solution

  • http://msdn.microsoft.com/en-us/library/ybce7f69%28v=vs.100%29.aspx

    Looks like you may need to be using XMLSerializer.

    Also if a non-nullable type (int for example) has a nil=true it looks like it'll throw an error. That's on the referenced page.