Nullable Integer ? (working with linq)
- by nCdy
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.