views:

61

answers:

1

I've got exception about convert NULL to Int32.

I've got a table from database with nullable tinyint

[Column(Storage="_StatType", DbType="tinyint NULL")]
public StatType : int { get { _StatType; } }

(to get C# code just replace variable's type)

and after making linq select

def StartLinq = linq <#from lpi in _CfgListParIzm
    where lpi.ID_ListParIzm==drr1
    select (lpi.StatType)
#> ;

StartLinq.ToArray()[0] can't be readed if that is null :-/

mutable STT : int = 0;
try
{
    _=int.TryParse(StartLinq.ToArray()[0].ToString(), out STT);
}
catch { | _ is Exception => () /* I don't care*/ }

upper code is very poor trick :( I wont use it.

+1  A: 

I don't know nemerle, but in C# you would make StatType a nullable integer (Nullable<int> aka int?) instead of a non-nullable one. That's the most logical solution - does nemerle support nullable value types?

Jon Skeet
yes I guess Nullable[int]
nCdy