6.11. Query Data from Multiple Collections

Problem

You need to execute a query based on the combined data from multiple collections.

Solution

Create a standard LINQ query, such as the ones described by the previous recipes in this chapter, and use the Join clause to join the data from multiple sources.

How It Works

If you have any experience with SQL, or other query languages, you will most likely recognize the need to join data from multiple sources. One of the most popular join functions available to Microsoft T-SQL is INNER JOIN, which returns only the elements from the first source that match elements in the second.

The.NET Framework 3.5 supplies the Join clause, which provides functionality equivalent to an inner join. Here is an example: ...

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.