List.Find 抛出 Nullable object must have a value 错误

List.Find throwing Nullable object must have a value error

Dim sipff As SystemInfoPropertiesForForm = listSystemInfoPropertiesForForm.Find(Function(f) f.ShowFieldPropertyTypeId = CInt(SystemInfoPropertyIds.ShowMilestone))

SystemInfoPropertiesForForm 是一个复杂类型,所有项目都可以为空。

CInt(SystemInfoPropertyIds.ShowMilestone) = 900

listSystemInfoPropertiesForForm 有 10 个项目

有什么想法吗?

使用以下代码解决了这个问题

Dim sipff As SystemInfoPropertiesForForm = listSystemInfoPropertiesForForm.Find(Function(f) f.ShowFieldPropertyTypeId.HasValue AndAlso f.ShowFieldPropertyTypeId.Value = CInt(SystemInfoPropertyIds.ShowMilestone))