Dynamic Collection Retrieval

Posts   
 
    
Jazz
User
Posts: 63
Joined: 12-Aug-2005
# Posted on: 07-Sep-2005 13:49:56   

Hi there,

LLBLGen is dynamic, my problem is... dynamic. :-) I got an entity that has several m:n related collections. What I need to retrieve is a certain collection identified by a string, so I traverse all collections using GetMemberEntityCollections and checking whether the string matches the type, after that I need to find a certain field value within the entities that are inside the collection, again using a string to identify the field.

I am not using prefetching so what I discovered is that my collections are always empty. Problem is, that I dont want to use prefetching as

1) I cannot prefetch certain collections as I just know which one I need at runtime and after the root entity is already fetched

2) dont want to prefetch all collections for memory and performance sake

Is it possible to "postfetch" collections later on? It should work because when I address the collection directly from the entity using indexing, I get valid values. The problem should be in traversing the entity using GetMemberEntityCollections and after that foreaching that ArrayList.

Regards, André

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 08-Sep-2005 05:09:15   

If prefetching isn't a viable solution then consider limiting (filter) your collections results by using PredicateExpressions. This will eliminate the need to walk each collection until a string comparison match is found. Performance will be beter and you can be assured your resultset only contains desired entities.

take a look at the: Generated code - Filtering and sorting, (Adapter/SelfServicing) page in the LLBLGen User Manual for details on using predicate expressions.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Sep-2005 10:54:59   

You can fetch a collection later on of course, though the fetch action has to be initiated by code, either with a prefetch path to fetch sub collections (and using a context, see the context help in the docs) or by a collection fetch as you used to do.

Frans Bouma | Lead developer LLBLGen Pro
Jazz
User
Posts: 63
Joined: 12-Aug-2005
# Posted on: 08-Sep-2005 13:07:18   

the problem ist, that the fetching has to be very generic, because i handle all collections as IEntityCollectionBase objects.

I also used the predicate expression stuff before, but dont really need it because for me it looks bit too complicated and I dont really expect a performance boost because the collection has to be iterated in any way. As in my context collection-typestrings inside that entity are unique I think I will go on using the foreach approach.

Regards, André