我正在尝试将 SQLValue 读入对象属性,但是我收到“字符串格式不正确”的错误“ModifyBy”属性设置为允许空值。这是返回错误的代码(引发错误的特定行是“ModifyBy”行):
public historycrumb(SqlParameter[] param)
{
CreateBy = param.Single(sp => sp.ParameterName == "@CreateBy").SqlValue != DBNull.Value ? Convert.ToInt32(param.Single(sp => sp.ParameterName == "@CreateBy").SqlValue.ToString()) : (Int32?)null;
CreateDateTime = Convert.ToDateTime(param.Single(sp => sp.ParameterName == "@CreateDateTime").SqlValue.ToString());
ModifyBy = param.Single(sp => sp.ParameterName == "@ModifyBy").SqlValue != DBNull.Value ? Convert.ToInt32(param.Single(sp => sp.ParameterName == "@ModifyBy").SqlValue.ToString()) : (Int32?)null;
ModifyDateTime = Convert.ToDateTime(param.Single(sp => sp.ParameterName == "@ModifyDateTime").SqlValue.ToString());
}