"Old Style" lazy loading
Old forum URL: forums.lhotka.net/forums/t/8351.aspx
whelzer posted on Thursday, January 14, 2010
Quick question on old style lazy loading a child collections, the article by Rocky dated 4/11/2003,
gives the following:
Private
mDetails As
Details = Details.NewDetails()
Public
ReadOnly
Property Details()
As Details
Get
If mDetails Is
Nothing Then
mDetails = Details.GetDetails(Me.ID)End If
Return
mDetails
End
Get
End
Property
My question related to the GetDetails method on the Details child object, should this operation be in a DP_Fetch? By definition child objects don't have DP_ methods so I'm a bit confused.
Any pointers much appreciated.
Sooner we away from version 3.0.4 the better!
Marjon1 replied on Thursday, January 14, 2010
Yes, the GetDetails should call a normal DP_Fetch, you just have to remember to still call MarkAsChild() and you are good to go.
The only other thing to highlight, is that the above code would never actually load the list because mDetails always has a value. The Details.NewDetails() call should be in the DP_Create if you are using one.
I am about to have to change about 2 dozen children lists from being loaded as part of the parent to being lazy-loaded, I wish I was on 3.6 or above!JoeFallon1 replied on Thursday, January 14, 2010
Or just initialize the variable like this:
Private mDetails As Details = Nothing
Marjon1 replied on Thursday, January 14, 2010
That's true, it just depends on if there is ever a real scenario to have a new list of details vs always fetching a list and it returning no items within.whelzer replied on Friday, January 15, 2010
Thanks for the responses. Works a treat..
Copyright (c) Marimer LLC