difference between select and where in LINQ

c#, linq

Solution

Where Filters a sequence of values based on a predicate. So in the first example you are selecting elements from your list where the function `n.Id == id` is true.

Select Projects each element of a sequence into a new form, so in your second example you get a list of booleans which is the result of the function `n.Id == id` on each element.

Problem

Possible Duplicate: Linq: What is the difference between Select and Where What's the difference between ``` var a = Doc.Document.Where(n => n.Id == id).SingleOrDefault(); ``` and ``` var b = Doc.Document.Select(n => n.Id == id).SingleOrDefault(); ``` Why variable b is a boolean ? Sorry about my ignorance, I am new to LINQ.

Original source

Related problems