QuerySpec deeper joins

Posts   
 
    
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 28-Jul-2012 22:35:07   

in the documentation for QuerySpec

var qf = new QueryFactory(); // using a related element query and an On() clause. var q = qf.Employee .From(QueryTarget .LeftJoin(qf.Order).On(EmployeeFields.EmployeeId==OrderFields.EmployeeId));

So if Employee relates to Order. Now if Order relates to OrderDetail, how do I continue the above example?


var qf = new QueryFactory(); 
// using a related element query and an On() clause. 
var q = qf.Employee 
    .From(QueryTarget 
        .InnerJoin(qf.Order).On(EmployeeFields.EmployeeId==OrderFields.EmployeeId))
        .From(??? QueryTarget or Order or ... 
               .InnerJoin(qf.OrderDetail).On(OrderFields.OrderId==OrderdetailFields.OrderId))
;

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 29-Jul-2012 10:28:57   

arschr wrote:

in the documentation for QuerySpec

var qf = new QueryFactory(); // using a related element query and an On() clause. var q = qf.Employee .From(QueryTarget .LeftJoin(qf.Order).On(EmployeeFields.EmployeeId==OrderFields.EmployeeId));

So if Employee relates to Order. Now if Order relates to OrderDetail, how do I continue the above example?


var qf = new QueryFactory(); 
// using a related element query and an On() clause. 
var q = qf.Employee 
    .From(QueryTarget 
        .InnerJoin(qf.Order).On(EmployeeFields.EmployeeId==OrderFields.EmployeeId))
        .From(??? QueryTarget or Order or ... 
               .InnerJoin(qf.OrderDetail).On(OrderFields.OrderId==OrderdetailFields.OrderId))
;

var q = qf.Employee 
    .From(QueryTarget 
        .InnerJoin(qf.Order).On(EmployeeFields.EmployeeId==OrderFields.EmployeeId)
        .InnerJoin(qf.OrderDetail).On(OrderFields.OrderId==OrderdetailFields.OrderId));

Please see the example queries shipped with the full installer (in Frameworks\LLBLGen Pro\Example queries\Queryspec) Simply keep on joining like you'd do in SQL as well. Notice the single ')' behind OrderFields.EmployeeId, so you'll get the .InnerJoin method to appear.

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 29-Jul-2012 14:02:47   

Thanks. I did look at the documentation, but didn't see examples showing cases beyond first level usage (i.e. more complicated situations). I'm sorry if I missed it, could you point me to more complicated examples that are in the docs?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Jul-2012 00:31:10   

Hi Al,

In the docs you will find examples that demonstrate the concepts. Often you won't find an exact example about you own case, but you can work on top of the basic ones.

Additional there are good complex examples at <LLBLGen Pro insttalation folder>\Frameworks\LLBLGen Pro\ExampleQueries\QuerySpec, as Frans mentioned.

David Elizondo | LLBLGen Support Team