LazyLoading child collections on new object

Posts   
 
    
Posts: 134
Joined: 10-Jan-2007
# Posted on: 23-Sep-2010 23:23:31   

I am seeing child collections issue database calls on new objects.

i.e. WebOrderEntity wo = new WebOrderEntity(); int x = wo.WebOrderFile.Count(); //Causes select from database where parent id = 0

This topic: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15181&HighLight=1 indicates 2.6 fixed this, but it seems to be back in 3.0?

SD.LLBLGen.Pro.ORMSupportClasses.NET20 - 3.0.10.915 Designer is the August 18th build.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Sep-2010 06:46:47   

We are looking into this trying to reproduce it.

David Elizondo | LLBLGen Support Team
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Sep-2010 04:43:15   

I reproduced your problem with v3 latest version. We are looking into this. In the meantime please use this code (not ideal, but it works):

WebOrderEntity wo = new WebOrderEntity();
wo.AlreadyFetchedWebOrderFile = true;
int x = wo.WebOrderFile.Count(); 

It looks like this wans't added to v2.6 due to customer requests (some customers want this): http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15753&StartAtMessage=0&#87864

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 27-Sep-2010 11:34:01   

Indeed, we didn't add it in v2.6/3.0. (3.0 mainly due to time constraints, as we focused on the designer mainly).

I've added a workitem to the v3.1 queue so it will be added in v3.1 with a setting. v3.1 is scheduled to go beta in december. (the setting is off by default, and can be enabled). In the mean time please use the workaround mentioned in the threads.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 27-Sep-2010 15:33:33   

I had not thought of setting the key, then calling the property. Makes total sense, in fact I do it myself.

It seems the best way to handle this would be to not load relationships where the entities PK is used and the entity is new. This should always result in a no-op.

If the new setting could work that way, it would be great. Should cover both cases pretty well.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Sep-2010 15:57:35   

I think it can be implemented like that.

Thanks.

Posts: 134
Joined: 10-Jan-2007
# Posted on: 27-Sep-2010 15:59:11   

Awesome smile