Built-in LINQ operators

As we have seen in the previous sections, there are no semantic differences between method syntax, and query syntax. In addition, some queries, such as those that retrieve the number of elements matching a specified condition, or those that retrieve the element that has the maximum value in a source sequence, can be expressed only as method calls. These kinds of methods are sometimes referred to as .NET Standard Query Operators and include as Take, ToList, FirstOrDefault, Max and Min.

In addition to those methods that can only be expressed as method calls, all the extension methods that can be used in either query syntax, or method syntax are also defined as standard query operators such as select, where, and from. So, the .NET Standard Query Operators contain all of the LINQ-related methods.

A complete list of these operators can be found at Microsoft MSDN library for class System.Linq.Enumerable.

To have a quick look at all those operations, in Visual Studio 2008, open the program.cs file, and type in System.Linq.Enumerable. Then, type in a dot after Enumerable. You will see the whole list of operators in the intellisense menu.

Built-in LINQ operators

The methods in this static class provide an implementation of the standard query operators for querying data sources that implement IEnumerable<(Of <(T>)>). The standard query operators are general-purpose methods that follow the LINQ pattern and enable you to express traversal, filter, and projection operations over data in any .NET-based programming language.

The majority of the methods in this class are defined as extension methods that extend IEnumerable<(Of <(T>)>). This means that they can be called like an instance method on any object that implements IEnumerable<(Of <(T>)>).

Note that this class was called System.Query.Sequence, and it was renamed to System.Linq.Enumerable just before Visual Studio 2008 was released, in February 2008. However, the old name was still used in much of the LINQ documentation, even in the official C# 3.0 Specification document. So, whenever you see the namespace System.Query or the class Sequence, or the namespace System.Dlinq, just substitute it with System.Linq.Enumerable, or System.Data.Linq. In the release version of .NET 3.5, there is no such thing as System.Query, or System.Dlinq.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset