New Posts New Posts RSS Feed: Object Graph Navigation
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Object Graph Navigation

 Post Reply Post Reply
Author
jozza View Drop Down
Newbie
Newbie


Joined: 11-Jul-2007
Posts: 25
Post Options Post Options   Quote jozza Quote  Post ReplyReply Direct Link To This Post Topic: Object Graph Navigation
    Posted: 17-Jul-2007 at 9:44pm
A quick question regarding the navigation of the object graph:
 
Say that I have an object, User. And from that object there is a relation to a collection of objects of type say, Preference. So given this you can do the following:
 
User user = PersistenceManager.DefaultManager.GetEntity<User>(...some query)
 
... And from there you can:
 
user.Preferences which returns a ReadOnlyEntityList<Preference>
 
... Now, my question is, is there anyway that you can then search this list on the key provided in the Preference Table? Or do you have to go back and use the PersistenceManager with a different more specific query to return the data you want? And if so, how would one formulate such a query?
 
I may be missing some vital concept (which I'm pretty sure that I am), but it would seem that the user.Preferences List is only useful if you want to bind the list to something. I on the other hand, would like to be able to navigate via code to the Preferences List and then perform some logic on specific items in the list. It is possible to iterate through the list and find the items of interest, but that just doesn't seem right.
 
 
 
Thanks.
 


Edited by jozza - 17-Jul-2007 at 11:49pm
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: 18-Jul-2007 at 9:14am

There is nothing wrong with either requerying the PersistenceManager or iterating through the list of child entities one by one.  In some cases. this may be the best strategy, but often the best strategy is to use an EntityListManager and a predicate to filter your child entities.  This is especially effective when you want your list of child entities to dynamically change without requerying the PersistenceManager.

Read about the EntityListManager in the Developer's Guide and/or study the EntityListManager tutorial (under the BindableList section of the Intermediate tutorials).  There is also a nice example of an EntityListManager in both FunHouse and Cabana.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down