Reputation: 409
I have the following linq query:
var test = vendorContact.vendorContactItem
.Where(x => x.ItemNumber == vendorContactItem.Item_Number)
.FirstOrDefault();
It fails on this piece of code, "Value cannot be null, parameter name: source" ... yet it also displays, in the local variables window, "test" as a variable with all its properties populated.
vendorContact.VendorContactItem
is null. Presumably this would be the first element to be added to the list. So how is "test" evaluating correctly while simultaneously throwing up that error?
I'm new to Linq, so excuse me if this is an obvious question.
Upvotes: 0
Views: 2228
Reputation: 47038
If this is in a loop test
in the locals window contains the last value of test
, from the last iteration of the loop.
Edit: This has really nothing to do with LINQ, but how the debugger works.
Upvotes: 1