views:

252

answers:

2

When I read code that uses Select I think "select-all-where". When I read code that uses Map I think "this-to-that" or "apply-to-all". I can't be the only person that feels the name Select is confusing.

Map

+8  A: 

It's really identical to map from functional languages. The reason it's named Select is that it's designed to be used as a part of LINQ which uses SQL-like keywords.

from item in collection
where item.Value == someValue
select item.Name

is translated to:

collection.Where(item => item.Value == someValue)
          .Select(item => item.Name)

it would be a little inconsistent if Select was named Map; something like:

collection.Filter(item => item.Value == someValue)
          .Map(item => item.Name)

In fact, many people use LINQ without having heard of functional programming at all. To them, LINQ is a method to retrieve data objects and query them easily (like SQL queries are). To them, Select and Where make perfect sense. Much more than Map and Filter.

Mehrdad Afshari
Makes complete sense. If I really cared that much I could wrap `Where` and `Select` in extension methods.
ChaosPandion
Good answer. I actually used "Select" without LINQ, but it's much clearer as a LINQ expression.
willem
A: 

One of the major reasons Select comes last is to make Intellisense work. By putting the source of the sequence first (from statement), Intellisense can work properly.

Randy Minder