I have a rather ugly service job that runs through a legacy database and compares it to our production database:
if (vendorContract.Item.Where(x => x.ItemNumber == contractItem.Item_Number) != null) { var oldDbContractItem = vendorContract.Item.Where(x => x.ItemNumber == contractItem.Item_Number).First(); // check to see if there were changes if (oldDbContractItem.DateStamp != vendorContractItem.Date_Stamp) { oldDbContractItem.Update(vendorContractItem); } } I will get an error on var oldDbContratItem, "Sequence contains no elements", yet I just did a != null check. This must be simple, what's going on?