New Posts New Posts RSS Feed: order by in child collection
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

order by in child collection

 Post Reply Post Reply
Author
Makani View Drop Down
Newbie
Newbie
Avatar

Joined: 15-Nov-2007
Location: United States
Posts: 7
Post Options Post Options   Quote Makani Quote  Post ReplyReply Direct Link To This Post Topic: order by in child collection
    Posted: 28-Nov-2007 at 8:44am
I have an object with a child collection.  I have tied the child collection to a grid.  It is not apparent to me how to pass an order by to the hydration of this collection. Do I have to use an Rdb subquery if I want an ordered child collection?
 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Nov-2007 at 12:38pm
You can set up your nested grid by using "chained binding" or by using "event handlers".  The advantage of using "chained binding" (as shown in the "Populating a WinForm" tutorial) is that there is absolutely no code to write.  The disadvantage is that you have no control over how the EntityList for the detail grid is populated.  Therefore, you will need to use an Event Handler.
 
The Event Handler that you will need is for the CurrentChanged event on the BindingSource to which your primary grid is bound.  When the CurrentChanged event fires on the BindingSource, just build a new EntityList.  Build the EntityList using an OrderBy clause.  Note that your query will be asking for all detail objects that have a parent id equal to the id of the currently selected parent.
 
 


Edited by davidklitzke - 28-Nov-2007 at 12:50pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down