In LINQ, projection is an operation which converts an object into the new form which holds only those properties that will be subsequently used. By using projection, a developer can create a new type which is built from each object. You are allowed to project property and conduct mathematical function on it, and you can also project the original object without transforming it.
In LINQ, the following projection operations are available:
The select operator returns the IEnumerator collection, which holds the items based on a transformation function. Or in other words, we can say that select operator is used when you want to select a single value from the given collection.
Select using Query Syntax: In LINQ, a Select operator is used in creating a query using query syntax. In the query expression, the expression ends with Select or GroupBy clause. In a query, the select operator is used to return the collection of the custom class or anonymous type that include the properties as per the need of the user and also used to manipulate the result according to the user need. Select operator support query syntax in both C# and
VB.NET language As shown in the below examples:
Employee Name: Anjita Employee Name: Soniya Employee Name: Rohit Employee Name: Supriya Employee Name: Anil Employee Name: Anju
Select using Method Syntax: In method syntax, the select operator is optional, you may use it to shape the data. The Select method is present in both the Queryable and Enumerable class. It supports method syntax in both C# and VB.Net languages. The use of the select method is shown in the below examples.
Employee Name : Anjita Employee ID : 209 Employee Name : Soniya Employee ID : 210 Employee Name : Rohit Employee ID : 211 Employee Name : Supriya Employee ID : 212 Employee Name : Anil Employee ID : 213 Employee Name : Anju Employee ID : 214
- LINQ | Projection Operator | SelectMany
- LINQ | Set Operator | Except
- LINQ | Partition Operator | Take
- LINQ | Quantifier Operator | Contains
- LINQ | Element Operator | First
- LINQ | Element Operator | Last
- LINQ | Quantifier Operator | All
- LINQ | Filtering Operator | where
- LINQ | Quantifier Operator | Any
- LINQ | Set Operator | Union
- LINQ | Set Operator | Distinct
- LINQ | Set Operator | Intersect
- LINQ | Sorting Operator | ThenBy
- LINQ | Equality Operator | SequenceEqual
- LINQ | Filtering Operator | OfType
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.