I'm not sure if it is possible so asking you.

public class Obj1
   public EntitySet<Obj1> ChildItems{get;private set;}

I have n levels of master detail.

Now im specifying [Field(LazyLoad=false)] but in some cases i don't need all the items. What is the best way to ask the DO to prefetch the child items collection?

Also is it possible to check without any additional property that it is the root item? Now i'm using IsRoot property set to true for top level objects.

so my query looks like

session.Query.All<obj1>().Where(o=>o.IsRoot == true)

asked Apr 27 '11 at 05:40

Janosh's gravatar image


One Answer:

Hello Janosh,

First of all, attribute LazyLoad = true doesn't make any sense on EntitySets, as they always are loaded on demand.

Secondly, I'd suggest you to add a paired back reference from child to parent, say:

public class Obj1
  public Obj1 Parent { get; set; }

  [Association(PairTo = "Parent")]
  public EntitySet<Obj1> ChildItems{get;private set;}

This will help you to detect roots in more graceful manner:

Query.All<Obj1>().Where(o => o.Parent == null);

Hope that helps.

answered Apr 27 '11 at 05:48

Dmitri%20Maximov's gravatar image

Dmitri Maximov

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Apr 27 '11 at 05:40

Seen: 3,291 times

Last updated: Apr 27 '11 at 05:48

powered by OSQA