August 2012
Intermediate to advanced
840 pages
22h 41m
English
LINQ provides several functions (implemented as extension methods) that are not supported by Visual Basic’s LINQ syntax. Though you cannot use these in LINQ queries, you can apply them to the results of queries to perform useful operations.
For example, the following code defines a query that looks for customers named Rod Stephens. It then applies the FirstOrDefault extension method to the query to return either the first object selected by the query or Nothing if the query selects no objects.
Dim rod_query = From cust In all_customers
Where cust.LastName = "Stephens" AndAlso cust.FirstName = "Rod"
Dim rod As Person = rod_query.FirstOrDefault()
The following list describes some of the more useful of these extension methods:
Read now
Unlock full access