Loading subtype entity using prefetch

Posts   
 
    
Posts: 44
Joined: 02-May-2014
# Posted on: 02-Jun-2014 09:20:04   

Hello,

I have the following problem, I try to load data and I'm using prefetch to load subtype (using adapter). Here is the relation : UnbundlingPot (main) <-- 1-Many --> UnbundlingInvoice <-- Many-1 --> UnbundlingCustomer (mark as subtype of InvoicingCustomer)

Here is my code :

var qf = new QueryFactory();
    var q = qf.UnbundlingPot
        .WithPath(UnbundlingPotEntity.PrefetchPathCurrency)
        .WithPath(UnbundlingPotEntity.PrefetchPathRiskCustomer
            .WithSubPath(RiskCustomerEntity.PrefetchPathInvoicingCustomers))

UnbundlingPot, UnbundlingInvoice and InvoicingCustomer are loaded correctly, but the UnbundlingCustomer (subtype of InvoicingCustomer ) is null. I can't see an option to prefetch this entity.

How can I get the subtype loaded ?

Thanks, Regards,

Using llblgen pro 4.1 Final, Framework .Net 4.5 (VS2012) and SqlServer 2012

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Jun-2014 17:48:43   

The query doesn't state what you describe. Also, multiple calls to WithPath does work but he should do: (define the path in 1 method call)

qf.UnbundlingPot
        .WithPath(UnbundlingPotEntity.PrefetchPathCurrency, UnbundlingPotEntity.PrefetchPathRiskCustomer.WithSubPath...)
Posts: 44
Joined: 02-May-2014
# Posted on: 03-Jun-2014 09:13:03   

Hi Walaa,

Thanks a lot, you right, my schema is a little bit complex and I go in wrong way to load sub data. It works like a charm now simple_smile .

What's the difference between one .WithPath call and multiple call, is it faster ?

Regards, Etienne.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39617
Joined: 17-Aug-2003
# Posted on: 03-Jun-2014 09:40:01   

yes, but not by much. Calling the method multiple times however might cause you specify paths which are to be defined together, separately:

First call: A-B-D Second call: A-B-C

this is will make the first path become hidden, as it's overwritten by the path in the second call as it stores just one path for A-B. The correct way would have been A-B-(D, C) so specifying D and C together. This is done by calling the methods just once. It takes some getting used to, as it forces you to think about a graph and specify it on a single line which is a bit counter intuitive simple_smile Glad it's working now.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 44
Joined: 02-May-2014
# Posted on: 03-Jun-2014 09:48:42   

Thanks for explanation.

I'll use this method also, we are chasing performance, even if it's a small gain, it's always appreciate wink