c# - entity framework only populating child on first item -


when using eager loading child elements database, first enrollment record on customer gets ordermembers populated. subsequent enrollment records has order on it, no ordermembers populated.

so have customer has 3 enrollments, each having order, , order having multiple people associated it. have confirmed information in database , have ran query gets generated entity framework, , data being returned ordermembers. ordermembers gets populated first enrollment being returned. other 2 enrollments have order no ordermembrs.

include statement:

dbcontext.customers.include(x => x.enrollments.select(order => order.ordersnapshot).select(p =>p.ordermembers) 

class structure:

public class customers {     public ilist<enrollment> enrollments {get; set;} }  public class enrollment {     public ordersnapshot order {get; set;} }  public class ordersnapshot {     public ilist<persons> ordermembers {get; set;} } 

i don't think have right syntax. should be

dbcontext.customers.include(x => x.enrollments.select(order => order.ordersnapshot.ordermembers)) 

see https://msdn.microsoft.com/en-us/library/gg671236(v=vs.103).aspx


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -