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.
vendorContact.VendorContactItemcannot be both null and an empty list. Which is it?fn(obj, p1, p2, ...). That is, they are not invoked upon a receiver (they are static methods) and thus can react to null (e.g. whenobj == null) how they choose to. Usually throwing an ArgumentNullException is appropriate. Not sure if this answers/explains your question though.