Reputation: 1071
I have a simple query as below:
Dim sizings = From a In db.Sizings
Where a.Customer.ID = customer.ID
Select a
If sizings.Any Then
.....
The sizings.Any
line is throwing a null reference exception. I thought I was meant to use .Any
to determine if there were any rows returned?
isnothing(sizings)
returns false
.
Any ideas?
Edit - Resolution: Don't use null objects in the LINQ Query!
Upvotes: 3
Views: 2081
Reputation: 100587
Try checking that Customer isn't null before comparing its ID.
Dim sizings = From a In db.Sizings
Where a.Customer IsNot Nothing And a.Customer.ID = customer.ID
Select a
If sizings.Any() Then
'
End If
Upvotes: 2