views:

405

answers:

2

I currently have two entities in LLBLGen and would like to merge them together to output to a table to be used in a DevExpress GridControl in the same way that 2 tables joined together with an inner join.

Does anyone know how to do this with LLBLGen?

+3  A: 

If you are using LLBLGen 2.6, you can use the LINQ to flatten the output using LLBLGen LINQ Provider.

Something on the way of (pseudo code)

var flat = from x in db.entitiesa()
           from y in db.entitiesb()
           select new { x.Name, y.Address }

and just throw variable 'flat' to the grid control.

DodyG
unfortunately, I'm on .net 2.0 for this project.
Tim Almond
+2  A: 

Then the alternative is creating a dynamic list (below code comes from the help file) - it is unfortunately quite verbose.

DataAccessAdapter adapter = new DataAccessAdapter();
ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(EmployeeFields.FirstName, 0, "FirstNameManager", "Manager");
fields.DefineField(EmployeeFields.LastName, 1, "LastNameManager", "Manager");
fields.DefineField(EmployeeFields.LastName, 2, "AmountEmployees", "Employee", AggregateFunction.Count);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.Add(EmployeeEntity.Relations.EmployeeEntityUsingEmployeeId, "Employee", "Manager", JoinHint.None);

IGroupByCollection groupByClause = new GroupByCollection();
groupByClause.Add(fields[0]);
groupByClause.Add(fields[1]);
DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, bucket, 0, null, true, groupByClause);
DodyG
Thanks. That's what looked like the "right" way to do it from the help files.
Tim Almond