Filter entity collection in-memory on related entities

Posts   
 
    
chrishilton avatar
Posts: 49
Joined: 26-Jun-2007
# Posted on: 23-Jul-2008 13:02:29   

I'm using LLBLGen Pro 2.5 with adapter and .NET 2.0/c# connecting to SQL Server 2005 dBs.

I see that in v2.5:

"It's now possible to filter an entity collection in-memory based on a filter on related entities and collections of related entities, for example all customers which have an order which is shipped today."

Could someone provide an example of how to create a combined filter that will filter on the entities in the colleciton and their related entities?

I have tried this but clearly don't have the related entity (ListName) filter correct:


PredicateExpression filter = new PredicateExpression();
filter.Add(ListNameFields.Type == listNameType);
filter.Add(ListValueFields.Type == listValueType);
List<int> indexes = eclListValues.FindMatches(filter);
if (indexes.Count > 0) return eclListValues[indexes[0]].RecId;

Cheers, Chris

chrishilton avatar
Posts: 49
Joined: 26-Jun-2007
# Posted on: 23-Jul-2008 15:27:19   

Hold that thought, I've found it ...


MemberPredicate relatedFilter = new MemberPredicate(ListValueEntity.MemberNames.ListName, MemberOperator.Any, (ListNameFields.Type == listNameType));

filter.Add(ListValueFields.Type == listValueType);
filter.Add(relatedFilter);