Query Expression Syntax Examples: Partitioning

 

The examples in this topic demonstrate how to use the Skip<TSource> and Take<TSource> methods to query the AdventureWorks Sales Model using query expression syntax. The AdventureWorks Sales Model used in these examples is built from the Contact, Address, Product, SalesOrderHeader, and SalesOrderDetail tables in the AdventureWorks sample database.

The examples in this topic use the following using/Imports statements:

[!CODE [DP L2E Examples#ImportsUsing](../CodeSnippet/VS_Snippets_Data/DP L2E Examples#importsusing)]

Example

The following example uses the Skip<TSource> method to get all but the first two addresses in Seattle.

[!CODE [DP L2E Examples#SkipNested](../CodeSnippet/VS_Snippets_Data/DP L2E Examples#skipnested)]

Example

The following example uses the Take<TSource> method to get the first three addresses in Seattle.

[!CODE [DP L2E Examples#TakeNested](../CodeSnippet/VS_Snippets_Data/DP L2E Examples#takenested)]

Queries in LINQ to Entities

Show: