Joining 2 tables without PK FK relationship

Posts   
 
    
J Dawg avatar
J Dawg
User
Posts: 1
Joined: 01-Sep-2006
# Posted on: 01-Sep-2006 21:28:23   

I am having an issue where I am trying to join to tables that are related, but do not have the typical PK to FK relationship.

Example:

Table A

ColA1 ColA2 ColA3

Table B

ColB1 ColB2 ColB3


column ColA2 and column ColB2 are related fields

I want to create a join in LLBL where I get ColA1,ColA2,ColA3 and ColB1

Anyone have any ideas? confused

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 02-Sep-2006 04:00:41   
// C#
ResultsetFields fields = new ResultsetFields(4);
fields.DefineField(TableAFieldIndex.ColA1, 0);
fields.DefineField(TableAFieldIndex.ColA2, 1);
fields.DefineField(TableAFieldIndex.ColA3, 2);
fields.DefineField(TableBFieldIndex.ColB2, 3);
IRelationCollection relations = new RelationCollection();
relations.Add(new EntityRelation(TableAFields.ColA2, TableBFields.ColB2, RelationType.OneToMany));

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

This dynaimc list should get the results you need. If you have any issues with it just let us know.