6.3. Control Query Results
Problem
You need to control (or transform) the results of a query in order to do either of the following:
Limit the amount of information returned.
Change the names of the properties returned.
Solution
Create a standard LINQ query, such as the one described in recipe 6-1, and use the Select clause to specify the exact value or values you need to return.
How It Works
Recipe 6-1 covered how to create a basic query using the From clause, such as the following:
Dim query = From book In books
This is the most basic form a query can take, and it simply returns all the results. In this case, assuming books is a collection of Book objects, the results of the query would be an IEnumerable(Of Book) collection containing all the ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.