我有关于将 NULL 转换为 Int32 的异常。
我从数据库中获得了一个可以为空的 tinyint 的表
[Column(Storage="_StatType", DbType="tinyint NULL")]
public StatType : int { get { _StatType; } }
(要获取 C# 代码只需替换变量的类型)
并在进行 linq 选择之后
def StartLinq = linq <#from lpi in _CfgListParIzm
where lpi.ID_ListParIzm==drr1
select (lpi.StatType)
#> ;
StartLinq.ToArray()[0]
如果为空则无法读取:-/
mutable STT : int = 0;
try
{
_=int.TryParse(StartLinq.ToArray()[0].ToString(), out STT);
}
catch { | _ is Exception => () /* I don't care*/ }
上面的代码是非常糟糕的技巧:(我不会使用它。