I encountered this error when registering a new transaction in my accounting project:
Error Sequence contains no elements
The code that gives an error:
public int GetCustomerIdByName(string name)
{
return db.Customers.First(c => c.FullName == name).CustomerID;
}
I don’t know English and I used google translator (:
Thanks.
I used FirstOrDefault() instead of First(), but I got this error:
‘Object reference not set
f an object.’
5