Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Sorting for the initial retrieval of a collection
 

Pages: 1
LLBLGen Pro Runtime Framework
Sorting for the initial retrieval of a collection
Page:1/1 

  Print all messages in this thread  
Poster Message
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 07-Oct-2004 17:03:11.  
I have an entity, ParentEntity, which has a collection of ChildEntity objects, exposed through property Children. When I access the children through the parent, I want them sorted in a particular order.
I used to use code like this:
Code:

dim p as new ParentEntity
dim sort as new SortExpression
'...
'create the appropriate sort expression
'...
p.Children.SortClauses=sort
p.FetchUsingPK(...)



Then p.Children would be sorted in the proper order.

Since I upgraded to the latest libraries and designer, this no longer works. When I do
Code:

p.Children.SortClauses=sort

the code attempts to fetch p.Children. Since p's primary key isn't set yet, it doesn't come back with anything, but the collection is still marked as fetched (_alreadyFetchedChildren=True).

Once I fetch p and then try to use p.Children, there's nothing in the collection, because the fetch isn't done again.

So what's the proper way to set the sort order for a relation, so the items are retrieved in the desired order? Am I supposed to do p.Children.GetMulti(...) after I've fetched p? It seems there needs to be a way to set the sort order before the initial fetch is attempted; otherwise there's always a redundant database read.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37455 posts
# Posted on: 07-Oct-2004 17:42:10.  
use p.SetCollectionParametersChildren(0, sorter);

The other methods like you use, p.Children... will trigger lazy loading.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 08-Oct-2004 16:24:40.  
Thanks--I overlooked that method
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.