Simple Join

Posts   
 
    
skhan
User
Posts: 15
Joined: 29-Mar-2011
# Posted on: 19-Dec-2011 19:32:03   

How can I achieve this simple join using LLGLGen Runtime and not LINQ...SelfService

SELECT o.custID, d.productID FROM order o INNER JOIN lineItem d ON o.orderID = d.orderID

with the following entities

OrderEntity LineItemEntity

Note:

  1. There are no JOIN and WHERE filters.
  2. I need one column from the Order table and one column from the LineItem table.

Result set could be and object collection or datatable, doesn't matter.

I am an active customer...if that would help speed things up simple_smile

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Dec-2011 00:16:51   

If I understand, you have not any relation mapped between these two entities. If so, you need to add a custom one. In this code I use DynamicLists:

// setup the fields to fetch
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(OrderFields.CustId, 0);
fields.DefineField(LineItemFields.ProductId, 1);

// build your custom relation
IRelationCollection relations = new RelationCollection();
relations.Add(new EntityRelation(
     OrderFields.OrderId, LineItemFields.OrderId, RelationType.OneToMany)

// fetch
DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, null, null, relations, true, null, null, 0, 0);

skhan wrote:

I am an active customer...if that would help speed things up simple_smile

We offer the same good and fast support even if you are not a customer wink

David Elizondo | LLBLGen Support Team
skhan
User
Posts: 15
Joined: 29-Mar-2011
# Posted on: 20-Dec-2011 01:16:10   

Thanks..."good and fast...ish support"...don't pinch me nerve boy!

daelmo wrote:

If I understand, you have not any relation mapped between these two entities. If so, you need to add a custom one. In this code I use DynamicLists:

// setup the fields to fetch
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(OrderFields.CustId, 0);
fields.DefineField(LineItemFields.ProductId, 1);

// build your custom relation
IRelationCollection relations = new RelationCollection();
relations.Add(new EntityRelation(
     OrderFields.OrderId, LineItemFields.OrderId, RelationType.OneToMany)

// fetch
DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, null, null, relations, true, null, null, 0, 0);

skhan wrote:

I am an active customer...if that would help speed things up simple_smile

We offer the same good and fast support even if you are not a customer wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 20-Dec-2011 10:55:09   

skhan wrote:

Thanks..."good and fast...ish support"...don't pinch me nerve boy!

You weren't satisfied with the speed your question was answered?

Frans Bouma | Lead developer LLBLGen Pro