Skip to content

Latest commit

 

History

History
181 lines (135 loc) · 17.1 KB

index.md

File metadata and controls

181 lines (135 loc) · 17.1 KB

101 LINQ Samples

dotnet try Enabled

Exploring LINQ using this tutorial

This tutorial starts with the fundamentals of LINQ. You can follow each page in order to explore all the elements of LINQ. Following step-by-step lets you explore LINQ from these fundamental queries through more complicated queries, up to the most complex uses.

Alternatively, if you're familiar with LINQ, you can jump to a specific section to refresh your knowledge, or learn new techniques. Here is the full list of samples:

Restriction operators: The where keyword

The where keyword or Where method provide this capability. These operators restrict, or filter, the input sequence to produce an output sequence.

Projection operators: The select keyword

The select keyword or Select method provide this capability. These operators create output sequence elements from input sequence elements. The output elements may be either the same or different types.

Use the Take, Skip, TakeWhile and SkipWhile methods to partition the input sequence. You can get a slice of the input sequence as the output sequence.

The orderby keyword, along with descending, and the OrderBy, ThenBy, OrderbyDescending and ThenByDescending LINQ queries are used to sort data output.

The GroupBy and into operators organize a sequence into buckets.

These operators provide functionality to compare multiple sets of data. You can find the intersection, union, all distinct elements and the difference between sets.

Sometimes you want to convert a query result set to a different kind of collection. These operators show how you can do this.

The methods First, FirstOrDefault, Last, LastOrDefault, and ElementAt retrieve elements based on the position of that element in the sequence.

These methods generate sequences of integers.

The methods Any and All test for elements that match a condition. Any checks for one element. All checks that all elements match the condition.

There are a number of methods that perform calculations on values in a sequence. Note that some of these methods require that the input sequence is a numeric type. Those methods are noted below.

These methods operate on entire sequences rather than elements of a sequence. They compare sequences or create new sequences from combining all elements.

You can use different query operations to specify eager execution instead of lazy execution.

These operations perform similar functions to SQL join operators. These work with any LINQ data source.