I’m trying to figure out the difference between Where(Expression) and Single(Expression).
Is the Expression passed into single forwarded to a Where function?
eg, are these two statements the same?
var result = context.Persons.Single(p => p.ID == 5);
var result2 = context.Persons.Where(p => p.ID == 5).Single();
Singlereturns you aPerson, whereas theWherewill return you anIEnumerable<Person>.Passing the where expression into the single is just syntactic sugar.
Both the lines are functionally equivalent. The first I imagine could be ever so marginally more efficient. It’s also easier on the eye in my opinion.