Method-Based Query Syntax Examples: Element Operators (LINQ to DataSet)


The examples in this topic demonstrate how to use the First and ElementAt<TSource> methods to get DataRow elements from a DataSet using the query expression syntax.

The FillDataSet method used in these examples is specified in Loading Data Into a DataSet.

The examples in this topic use the Contact, Address, Product, SalesOrderHeader, and SalesOrderDetail tables in the AdventureWorks sample database.

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

For more information, see How to: Create a LINQ to DataSet Project In Visual Studio.

This example uses the ElementAt<TSource> method to retrieve the fifth address where PostalCode == "M4B 1V7".

This example uses the First method to return the first contact whose first name is 'Brooke'.