Building Complex Queries with Anonymous Types

Same as you would do with other LINQ providers, you can build complex queries taking advantage of anonymous types in LINQ to DataSets. The following code shows how you can join information from the Orders and Order_Details tables retrieving information on order details for each order made by the given customer. Projection is accomplished generating anonymous types:

image

The query variable is of type IEnumerable(Of Anonymous type), which is different from normal queries. Remember that IEnumerable results cannot be edited; therefore, you are limited to presenting data through specific controls such as BindingSource ...

Get Visual Basic® 2010 Unleashed 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.