Tim Almond
Tim Almond

Reputation: 12726

LLBLGen "Flattening" Table Relations

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?

Upvotes: 2

Views: 1203

Answers (2)

DodyG
DodyG

Reputation: 501

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);

Upvotes: 2

DodyG
DodyG

Reputation: 501

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.

Upvotes: 3

Related Questions