Taha22

Hello,

Unless I'm missing something, there appears to be an incompatibility between how the .NET xsd.exe tool generates types targeted for dataset access (/d option) and for generic class use (/c option).

If a type is declared "nillable" in the XML schema, e.g.

* <element name="prDiscount" type="int" nillable="true" />

then for the generated .cs file (/classes option) a corresponding nullable type is created:

* private System.Nullable<int> prDiscountField;

however, for the generated .cs file '/dataset option' the insert row method appears to be accepting value types only:

* public ... AddPromotionRow(... , int prDiscount, ...

A workaround can be to use another integer value to indicate null, but that defeats the purpose of using XML for database integration.

Thanks in advance
Taha



Re: XML and the .NET Framework Nullable type and XML xsd.exe tool

Robert Rossney

The ADO.NET DataSet's implementation of nullable columns in typed data sets predates Nullable<T>. You'll also find that the generated property accessors are of non-nullable types; the way to determine whether a column in a given row is NULL is to use the Is<column name>Null() method that xsd.exe generates for every nullable column.

The generated Add<table name>Row() method is, as you've seen, kind of, well, let's just call it less than fully functional.

That said, you can still add rows with null columns to the DataTable. You just have to use the untyped Add() method to do it. And the DataSet handles round-tripping of data with null columns via XML just fine.