PathEdge and FilterLambda

Posts   
 
    
sybjeb
User
Posts: 81
Joined: 20-Sep-2011
# Posted on: 10-Sep-2013 15:59:46   

Hi,

Is there a way to filter a prefetch node using PathEdge? I have been able to do it using the Linq equivalent way but don't want to do it because all of my prefetches are done using PathEdge.

Example : the accounting_number table has a FK_company_Id column How can I retrieve the accounting numbers of a specified company,

            query = query.WithPath
            (
                new PathEdge<AppellationEntity>
                (
                    AppellationEntity.PrefetchPathAccountingNumberDetails,
                    new PathEdge<AccountingNumberDetailEntity>
                    (
                        AccountingNumberDetailEntity.PrefetchPathAccountingNumber
                    )
                )
            );

Thanks in advance

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Sep-2013 08:22:56   

You can just pass a lambda expression filter the PathEdge's ctor. Like this:

 query = query.WithPath
        (
            new PathEdge<AppellationEntity>
            (
                AppellationEntity.PrefetchPathAccountingNumberDetails,
                new PathEdge<AccountingNumberDetailEntity>
                (
                    AccountingNumberDetailEntity.PrefetchPathAccountingNumber,
                    an => an.CompanyName == "ABC"
                )
            )
        );

More info about filtering PrefetchPaths at: http://www.llblgening.com/archive/2009/10/prefetchpaths-in-depth/#filteringandsorting

David Elizondo | LLBLGen Support Team