entity framework - EF4 Include() Children for sub class -


for purpose of questions, let's assume have these 2 entities defined in model -

public class person {     public guid id     {         get;         set;     }      public string name     {         get;         set;     } }  public class parent : person {     public ienumerable<person> children     {         get;         set;     } } 

let's assume have personrepository loads people database. people in database parent entity , therefore have children defined.

my question is, when load list of people repository, possible instruct linq include() children should of people parent entity?

btw, lazy-loading not work in instance repositories used within service layer.

thank help.

james

unfortunatelly directly possible way is:

 mycontext.persons.oftype<parent>.include("children")... 

the problem approach load parents. so possible solution can complex linq query have 2 parts connected .contcat or .union. 1 part query persons , second part query parents included childrens. edit: work in memory (ienumerable) not in db (iqueryable).

so other way can run person query first , execute second query parents returned in first query.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -