Lazy load seems not working in SelfServicing

Posts   
 
    
B.O.Dow
User
Posts: 4
Joined: 13-Mar-2010
# Posted on: 15-Mar-2010 12:16:30   

Hello.

I study the latest demo version (please notice I am a new user for LLBLGen Pro). I have a typical Customer - Orders example, and I use the SelfServicing template.

My model has the typical CustomerEntity, OrderEntity and CustomerEntity.Orders collection property. My code:

IPredicateExpression filter = new PredicateExpression();
filter.Add(// some code here);
filter.AddWithAnd(// some code here);
..
CustomerCollection customers = new CustomerCollection();
customers.GetMulti(filter)

I am not very sure that the lazy-loading mechanism works here! (I feel a performance issue..) and I try to find if something is wrong. Debuging the code in Visual Studio, just after the customers.GetMulti(filter) line, I watch:

?customers[0]:
.AlreadyFetchedOrders = true
.AlwaysFetchOrders = false
.Orders   --->  { Collection of entities...current number of elements: 2 }

(same for customers[n] for every n)

Is this an evidence that lazy loading on Orders collection didn't worked? What is my fault? Is something that I don't understand well? Please excuse my ignorance if this is something simple flushed

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 15-Mar-2010 15:03:28   

I guess you have confused LazyLoading with PrefecthPaths.

LazyLoading means for each fetched Customer, his Orders will only be loaded when accessed or requested. So Orders were not loaded up front.

On the contrary, PrefetchPaths loads all Customers' Orders up front in one shot using only one extra database Query.

B.O.Dow
User
Posts: 4
Joined: 13-Mar-2010
# Posted on: 15-Mar-2010 15:25:07   

Walaa wrote:

I guess you have confused LazyLoading with PrefecthPaths.

LazyLoading means for each fetched Customer, his Orders will only be loaded when accessed or requested. So Orders were not loaded up front.

On the contrary, PrefetchPaths loads all Customers' Orders up front in one shot using only one extra database Query.

Walaa thanks for your answer. I suppose I have understood the concept and the difference between them. Let me explain better (I hope..):

I DO NOT want to load the .Orders I just like to have a CustomerCollection loaded with ONLY the [Customer's Table] fields! I suppose this is what loading-on-demand does out of the box, right? I try to inspect if this really works or not, (i repeat, I don't want the .Orders collection to be loaded at once!) and I 'm searching for the method (I mean: "how to test it"). I know that if I code something like:


customers.GetMulti(filter); -- this fetches xxx rows for sure
MessageBox.Show(customers[0].Orders.Count);

then, the lazy-load mechanism will start and Orders of cutomer's[0] will be loaded. How I know, just after .GetMulti() call, that [Orders] table hasn't be queried yet?

I write:

customers.GetMulti(filter);
if (customers[0].AlreadyFetchedOrders) MessageBox.Show("Yes");

and the answer is "Yes" Is this normal?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 15-Mar-2010 19:23:14   

AlreadyFetchedOrders should be false. Could you please specify the llblgen runtime library version/build used?

(Edit) In the meantime, just for the sake fo testing, you may use Trace switches to output generated SQl queries into the VS output window while Debugging. Please use this to check if the OrdersCollections were fetched or not.

Thanks.

B.O.Dow
User
Posts: 4
Joined: 13-Mar-2010
# Posted on: 15-Mar-2010 21:02:26   

I suppose you mean SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll Version 2.6.0.0

(I don't know how to trace queries. Sorry. Can you give me some advices? wink )

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Mar-2010 04:17:16   

Here are information about Tracing and Debugging.

Also, be sure you don't have any debug watches pointing to .Orders or something like that in your VSNet as that also will trigger lazy loading.

David Elizondo | LLBLGen Support Team