[Mono-list] XSD creates buggy typed datasets

Juergen Frieling jfrieling@cis-comsoft.de
Fri, 29 Oct 2004 13:21:02 +0200

Hi all,

is anybody working with strongly typed datasets?

I know the CustomDataClassGenerator is marked unfinished but thought this
was only because of missing serialization.

Anyway, here is what I found out:

Im loading a plain DataSet and then do 'ds.WriteXmlSchema("test_ds.xsd");' -
result is given to 'XSD test_ds.xsd /dataset'

This is a column-property of the created typed DataRow - see comments
public virtual short nr {
    get {
        // next line (XSD-created) throws NullReferenceException because
        // InitializeFields for the table is never called and so the 
        // column-variables aren't set. Calling it after InitializeClass
        // in the table-constructor makes this work (don't know where it
        // *really* should be called...).
        object ret = this[this.table.nrColumn];

        if ((ret == System.DBNull.Value)) {
            throw new System.Data.StrongTypingException("Cannot get strong
typed value since it is DB null.", null);
        else {
            // next line (XSD-created) throws InvalidCastException
            // the equivalent for strings seems to work
            return ((short)(ret));
            // this works
            return Convert.ToInt16(ret);
    set {
        this[this.table.nrColumn] = value;

BTW: This would have been much easier with a working debugger. I read
someone is working on it - does anybody know when it is planned to be ready?