Posts   
 
    
mzohreh
User
Posts: 6
Joined: 07-Dec-2004
# Posted on: 22-Jan-2008 17:51:24   

Hi,

I have been trying for the past hour to do a simple join but cannot reproduce the code using LLBLGen Pro. The join is as follows:

SELECT * FROM CalendarEventCategory CE, meeting_type M WHERE CE.MeetingTypeId = M.Meeting_Type_Id AND CE.CalendarEventCategoryId = @CalendarEventCategoryId

How do I recreate this in LLBLGePro. Do i need to use the relation classes?

I'm using the VS 2005, C# and LLBLGen Pro 2.0 (Selfservicing).

Majid

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 22-Jan-2008 19:00:05   

yes, you should use the relations class (assuming it exists a relation between these tables, otherwise you need to create this relation by yourself) and if you want to retrieve all fields from both tables you need to use a dynamic or typed list. see the dynamic list reference for details. Let me know if you need further help.

mzohreh
User
Posts: 6
Joined: 07-Dec-2004
# Posted on: 23-Jan-2008 09:44:16   

Thanks for your reply. Would it be possible for you to post some sample code?

Thanks

Majid

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Jan-2008 10:03:12   

Check out the following code: (not compiled or tested)

ResultsetFields fields = new ResultsetFields(X); // whatever the count of your fields

fields.DefineField(CalendarEventCategoryEntity.CalendarEventCategoryId, 0);
fields.DefineField(CalendarEventCategoryEntity.myField1, 1);
fields.DefineField(MeetingTypeEntity.myFieldx, 2);
...

IRelationCollection relations = new RelationCollection();
relations.Add(CalendarEventCategoryEntity.Relations.MeetingTypeEntity);

PredicateExpression filter = new PredicateExpression();
filter.Add(CalendarEventCategoryEntity.CalendarEventCategoryId == XYZ)
// The following should work too.
// filter.Add(fields[0] == XYZ)

DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();

dao.GetMultiAsDataTable(fields, dynamicList, 0, null, filter, relations, true, null, null, 0, 0);
mzohreh
User
Posts: 6
Joined: 07-Dec-2004
# Posted on: 23-Jan-2008 17:19:41   

Thanks Walaa. I'll test the code and let you know the outcome.

Thanks

Majid

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Jan-2008 17:46:19   

Alright I'll close the thread for now, and it will be automatically re-opened if you post a reply.