RelationPredicateBucket on EntityView2

Posts   
 
    
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 02-Aug-2018 15:50:54   

The following filter we have build .


RelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(VariablesEntity.Relations.VariableClassesEntityUsingClassID);
filter.Relations.Add(VariableClassesEntity.Relations.VariableTypesEntityUsingTypeID);
filter.PredicateExpression.Add(new PredicateExpression(VariableTypesFields.ID == aVariableTypeID));

When using this in combination with DataAccessAdapter.FetchEntityCollection it is working fine. We see the number of VariablesEntity as expected.

When using this in combination with EntityView2 it seems not to work as expected?! For EntityView2 we are using filter.PredicateExpression .


mVariablesView.Filter = filter.PredicateExpression;

Version: 5.1.1

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 02-Aug-2018 19:53:15   

EntityView allows you to filter collections on properties of the entities included, not on related entities.

You can use Linq2Objects to deep filter a collections.

e.g.

using (var adapter = new DataAccessAdapter())
{
    var orderDetails = new EntityCollection<OrderDetailEntity>();
    var prefetchPath = new PrefetchPath2(EntityType.OrderDetailEntity);
    prefetchPath.Add(OrderDetailEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathCategory);

    adapter.FetchEntityCollection(orderDetails, null, prefetchPath);

    var q = from od in orderDetails
            where od.Product.Category.CategoryName == "Seafood"
            select od.OrderId;

    var list = q.ToList().Distinct();
}

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 03-Aug-2018 08:43:02   

Thanks!

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 10-Aug-2018 11:48:59   

Well I'm not satisfied after all, because your solution is filtering, but we like to use a mechanism that is working on the fetched entity collection.

The fetched collection, or the view, we assigned it to a lookup edit in a particular Form. In another form the collection can be extended, without a re fetch of the collection (new row in the grid). In the first form we like to show the new item in the lookup edit. The idea of the view is great, but not if it is impossible to filer on related entities. Is there another possibility then the one you gave me?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 10-Aug-2018 12:00:14   

An entity view accepts a predicate expression, you can use a delegatepredicate for in-memory filtering on related entities which should work I think, see: https://www.llblgen.com/Documentation/5.4/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Filtering%20and%20Sorting/gencode_filteringpredicateclasses.htm#delegatepredicate-and-delegatepredicateof-t

Or use a MemberPredicate, the example is right below it. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 22-Aug-2018 13:52:34   

Thanks, now I get it ;-)