Is There a single point for FetchEntityComplete??

Posts   
 
    
Harry
User
Posts: 73
Joined: 26-Jun-2007
# Posted on: 03-Dec-2008 17:42:56   

I have a situation where I need to be able to retrieve additional information for an entity after it is fetched. How can I ensure this data is retrieved?

I have looked through the dataaccessadapter code and have been able to solve this problem for when a FetchEntity call is made. The problem, however, is when an entity is loaded as part of a FetchEntityCollection. This method uses a completely different set of routines to populate the object and there are no virtual methods that I can find for which to override.

As an example consider Order and OrderItem. Lets say that I want to ensure that every time an Order item is loaded from the database, via my adapter, that it always loads the list of OrderItems.

How would I go about doing this?

Thanks.

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 03-Dec-2008 21:33:01   

Don't know if this is the right answer, but I would probably try the following.

I would ensure there was a prefetch path specified (create it if needed) and inspect and modify the prefetch path to ensure that whenever order was specified so was orderitem.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Dec-2008 07:38:27   

Maybe this could be helpful for you: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=14557

David Elizondo | LLBLGen Support Team
Harry
User
Posts: 73
Joined: 26-Jun-2007
# Posted on: 04-Dec-2008 13:46:27   

Thank you for the last 2 postings, however neither has been helpful.

I am hoping to avoid coding directly into unrelated event handlers or methods. I am also looking for a way to handle the situation I have in 1 place. In the dataaccessadapter code an entity is "loaded" with data from the database in 2 seperate places using 2 different approaches.

FetchEntity uses FetchEntityUsingFilter which triggers the event OnAuditLoadOfEntity after all data has been fetched.

FetchEntityCollection uses FetchEntityCollectionInternal uses ExecuteMultiRowRetrievalQuery which triggers the event OnAuditLoadOfEntity after the entity fields have been loaded and the entity has been added to the collection but before the rest of the data (prefetch path) has been loaded.

Is there a reason for the discrepancy in how this event is being raised?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Dec-2008 14:29:20   

The "always prefetch" issue was discussed here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=13930

Harry
User
Posts: 73
Joined: 26-Jun-2007
# Posted on: 04-Dec-2008 15:00:54   

Walaa, thanks for the post.

I feel as if there is some confusion on what it is I am trying to accomplish. I have no desire to deal with any entity _**prior **_to it being fetched or loaded. What I would like to do is inspect it _**after **_it is loaded and perform some operations, where necessary, using the same adapter that was used to load the entity (for the case of transactions).

The properties I would be setting may or may not be related to other objects in the current objects graph. So from my example on the Order I may want to set a property that has nothing to with the Order Item.

I was hoping that would be a single place somewhere in the adapter that would signal when an entity has completed being loaded (fields) and completed loading its related data (prefetch). But it appears there is none. cry

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 04-Dec-2008 15:53:54   

There's no single point of 'this entity has been fully fetched' because the hierarchical fetching is distributed, so the entity doesn't know about it, nor does logic which fetches that entity.

You could use the ObjectGraphUtils class to get hold of sets of entities in a graph and work on those sets, including adjacency lists for traversing edges. It might help you write generic code which accepts a graph and performs operations on it.

Frans Bouma | Lead developer LLBLGen Pro