List.Find抛出Nullable对象必须有一个值错误

时间:2016-04-19 20:40:35

标签: asp.net vb.net entity-framework linq edmx

ErrorListener

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

CInt(SystemInfoPropertyIds.ShowMilestone)= 900

listSystemInfoPropertiesForForm有10个项目

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

使用以下代码修复此问题

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