我有以下代码:
var distinctRows =
(from row in ds.GetTable(this.TagShortName).AsEnumerable()
select new Audit
{
ID =row.Field<long>("ID"),
UpdatedBy =string.Format("{0} {1}",
row.Field<string>("UpdatedByFirstName"),
row.Field<string>("UpdatedByLastName")),
UpdatedOn = ow.Field<DateTime>("UpdatedOn")
}).Distinct(new AuditComparer());
当我在 UpdateOn 字段中有空值时,它会抛出异常:
UpdatedOn =row.Field<DateTime>("UpdatedOn")
异常:无法将 DBNull.Value 转换为类型“System.DateTime”。请使用可为空的类型。
如何处理?