Given the following LINQ where clause :
plannedPosition.Id is of type int?
pmArray is of type int[]
//Works
where
pmArray.Contains(plannedPosition.Id.Value)
//Does not work - will give a design time error
where
pmArray.Contains(plannedPosition.Id)
开发者_如何学编程
How can I make the query more robust to ensure that no null run type exceptions occur?
How about:
where plannedPosition.Id != null && pmArray.Contains(plannedPosition.Id.Value)
精彩评论