Search code examples
.netormllblgenpro

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?


Solution

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