Hi
I'm using LLBLGen 4.2
I was wanting to optionally add relations at runtime prior to a FetchTypedList call. The only way I could see to do this was via the following where I added the relations to a RelationPredicateBucket and it came back in the DataTable object.
This is ok... but I'd prefer to do it via a populated typedlist, so take advantage of all the typing + classes.
Populating via datatable:
// get current relations
var orderLocations = new OrderLocationTypedList();
var filter = new RelationPredicateBucket()
var relations = (RelationCollection)orderLocations.GetRelationInfo().Relations;
foreach (var thisRelation in relations) {
filter.Relations.Add((IEntityRelation)thisRelation);
}
if (somecondition) {
// add extra relations for extended condition
filter.Relations.Add(SalesOrderLinesEntity.Relations.SalesOrderEntityUsingOrderNo, "", "", JoinHint.Inner);
filter.Relations.Add(ProductEntity.Relations.SalesOrderLinesEntityUsingProductNumber, "", "", JoinHint.Inner);
filter.PredicateExpression.Add(ProductFields.Department == new string [] { "someval1", "someval2" });
}
// fetch data into datatable
var fields = orderLocations.GetFieldsInfo();
var results = new DataTable();
adapter.FetchTypedList(fields, results, filter, false);
I would prefer to call it filling the typedlist, but could only do this where filter = PredicateExpression rather than the Bucket, and couldn't see how to add relations at runtime. Am I missing something obvious?
var orderLocations = new OrderLocationTypedList();
var filter = new PredicateExpression();
// add some conditions
adapter.FetchTypedList(orderLocations, filter, 0, null, false, 0, 0);