Advantage filtering

Posts   
 
    
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 25-Oct-2016 16:02:07   

I find it difficult to understand the filtering with LLBLGen. In the attachment you will find the database structure of ReportRibbonItems - ReportsReportRibbonItems - Reports

I like to have all reports based on particular ReportRibbonItem where ReportsReportRibbonItemsEntity.IsActive = true

Now I have the following code without the extra filter: prefetchPath.Add(ReportRibbonItemsEntity.PrefetchPathReportsCollectionViaReportsReportRibbonItem, 0, null, null, sorter_local6)

Attachments
Filename File size Added on Approval
Reports.png 15,659 25-Oct-2016 16:02.27 Approved
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 25-Oct-2016 19:02:03   

Filtering is something and PrefetchPaths is completely a different thing.

Prefetchpaths are used to fetch related entities (a graph of connected entities) in one shot (precisely, one query for each entity type).

For filtering on related entities, as with plain SQL, you need to JOIN(use relations) then use predicates.

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 26-Oct-2016 09:26:18   

I need to extend the ReportRibbonItem with Reports collection via the N:N table ReportsReportRibbonItems. The prefetchpath does that for me.

The restriction: ReportsReportRibbonItemsEntity.IsActive = true I like to add to the prefetchpath: prefetchPath.Add(ReportRibbonItemsEntity.PrefetchPathReportsCollectionViaReportsReportRibbonItem, 0, null, null, sorter_local6)

The 3th and 4th parameter (additional filter / additional filter relation) should do this, but how ??

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 26-Oct-2016 17:47:57   

You have figured it out.

var additionalFilter = new PredicateExpression(ReportsReportRibbonItemsFields.IsActive == true);

var additionalFilterRelations = new RalationCollection();
additionalFilterRelations.Add(ReportsEntity.Relations.ReportsReportRibbonItemsEntity);

prefetchPath.Add(ReportRibbonItemsEntity.PrefetchPathReportsCollectionViaReportsReportRibbonItem, 0, additionalFilter, additionalFilterRelations, sorter_local6) 

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 02-Nov-2016 11:50:02   

Thanks