Imports Telerik.OpenAccess

Module Module1

    Sub Main()
        Using scope As IObjectScope = ObjectScopeProvider1.ObjectScope()

            ' Get a List of all Customers
            '------------------------------------------------------------------
            Dim query As Query(Of Customer) = _
              scope.GetSqlQuery(Of Customer)("select * from Customers", "")
            Dim customers As QueryResultList(Of Customer) = query.ExecuteList()

            ' For Each Customer Found, Iterate through and find Customer Name, Orders, and Products
            '------------------------------------------------------------------
            For Each customer As Customer In customers
                Console.WriteLine("Customer: {0}:", customer.CompanyName)
                For Each order As Order In customer.Orders
                    Console.WriteLine(vbTab & "Order: {0}:", order.OrderID)
                    For Each orderDetail As OrderDetail In order.OrderDetails
                        Console.WriteLine(vbTab & vbTab & "Product: {0}:", _
                          orderDetail.Product.ProductName)
                    Next
                Next
            Next
        End Using

        Console.ReadLine()

    End Sub

End Module
