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 by generating anonymous types:

Private Sub QueryOrderDetails(CustomerID As String)    Dim query = From ord In NwindDataSet.Orders                Where ord.CustomerID = CustomerID                Join det In NwindDataSet.Order_Details                On det.OrderID Equals ord.OrderID                Select New With {.OrderID = ord.OrderID, ...

Get Visual Basic 2015 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.