linq - Difference between Where and Single -


I am trying to find out the difference between where (expression) and singular (expression).

Is the expression forwarded to a single where a function is sent to?

For example, are these two statements equal?

  var result = context.psons. Single (P = & Gt; PIID == 5); Var result2 = context.Persons.Where (P => PIID == 5). Single ();  

single gives you a person < / Code>, while where gives you a IEnumerable & lt; Person & gt; will return.

Where there is an expression in singles, it is just syntactic sugar.

Both lines are functionally equivalent, first I imagine that by now it is far more efficient. In my opinion it is also easy on the eyes.


Comments