This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a model (3.0 RC1) hooked up to a WPF TreeView and HierachicalDataTemplate When I load the main elements of the Tree I have an aggregate on all the child relations I want to load. I check the output and all queries run good for the aggregate. Then when I click on the child elements queries are run again to fetch the child EntityCollections. I have turned off all non-essential eager loading and cant understand why so many queries are run on a simple TreeView that only accesses one property of the Entity (Lazy loading should not be an issue) Does an EntityCollection need to load again if the items have already been loaded from an aggregate relational query? |
|
|
If you run an explicit query for the children e.g. Entity.Attribute("ParentId") == parent.Id then that will not mark the collection as loaded. (LightSpeed doesn't know that this query happens to map exactly to the collection.) The collection is marked as loaded only when it is eager-loaded (including via a named aggregate) or is explicitly referenced (e.g. parent.Children). From what you're describing, assuming that on your child elements you just refer to a further collection e.g. child.Grandchildren then that should not result in a further database hit if the Grandchildren collection was part of the named aggregate. An exception to this is if there are cycles in the eager load graph (including self-joins). I believe the eager load process will stop if it encounters the same table a second time. So if your tree is a homogeneous hierarchy (e.g. Person entities with Child relationships) then that could explain the behaviour you're seeing. If this doesn't help, could you say more about how you're querying the hierarchy and what the eager load relationships are, and we'll see if we can see what's going on? Thanks! |
|