Quick Objects Documentation Akal Tech Logo
Joins With LINQ and Quick Objects

Glossary Item Box

Business Logic Framework - Tutorial 38:

LINQ provides couple of different ways to create joins, however each method requires that you know the fields that are used in the join. In this tutorial you will see how you can use the LINQ method of creating joins as well as using the method call convention of creating joins that has been the primary way of joining in Quick Objects prior to LINQ support.

using  (Customers customers =  new Customers())  
{   
    Orders orders =  new Orders();  
    var result = from c  in customers  
                 join o  in orders on c.CustomerID equals o.CustomerID  
                 orderby o.OrderDate descending  
                 select c;  
 
    // You can further customize the query using the regular API if you prefer and you can   
    // also use the Find method on the business object directly and bind the results to grid.  
    this.GridView1.DataSource = customers.FindAndReturnTable();  
 
Using customers  As Customers =  New Customers()  
    Dim orders  As Orders =  New Orders()  
    Dim result = From c  In customers _  
                 Join o  In orders  On c.CustomerID Equals o.CustomerID _  
                 Order By o.OrderDate Descending _  
                  Select c  
 
    Me.GridView1.DataSource = customers.FindAndReturnTable()  
End Using  
 

Alternate Method (create joins by the older versions).

using (Customers customers = new Customers())  
{  
    customers.Join_CustomerID_Orders_Child();  
 
    var result = from c in customers  
                 orderby c.CustomerID_Orders_Child.OrderDate descending  
                 select c;  
 
    this.GridView1.DataSource = customers.FindAndReturnTable();  
}  
 
Using customers As Customers = New Customers()  
    customers.Join_CustomerID_Orders_Child()  
    Dim result = From c In customers _  
                 Order By c.CustomerID_Orders_Child.OrderDate Descending _  
                 Select c  
 
    Me.GridView1.DataSource = customers.FindAndReturnTable()  
End Using