EF DbSets with Master.Include("Detail")

edited May 2012
Hi there,

Bit of background. Using the ObjectContext in a querying e.g. from o in Orders.Include("Orderlines")... select oLinqPad will output the orders as well as order lines in the result pane. When using DbSet and POCOs LinqPad only outputs the Order properties. Lazyloading is off so I'm not sure what else to try.

Any help would be greatly appreciated.
Thanks

Comments

  • The problem is that with POCOs, LINQPad has know way of knowing that it can walk collection properties such as OrderLines without initiating futher queries.

    There are a couple of workarounds. One is to select new { o, o.OrderLines }. Another is to use results-to-grids mode, which generates hyperlinks for each association property.
  • I'm now using grid mode as suggested and it's giving me an easier way of testing queries, thanks for that.

    The strange thing is that all "excluded" collections returns (null) in the grid which leads me to think the LINQPad can indeed walk only populated collections without having to hit the DB.
  • Have you tried turning LazyLoading on? That way, "excluded" collections should give you a hyperlink that populates on demand rather than evaluating to null.
  • I was just hoping that since the those collections return null LINQPad could be updated to walk all the collections when LazyLoading is off. Basically just rendering the same as non-POCOs. Your initial advice still saves me lots of time since I can plug the query directly into code as is after testing it.
  • If LazyLoading is off, then it's impossible for LINQPad to walk the collections with POCOs. There are no tricks it can use to populate the collections, because, by definition, POCO collections are just ordinary collections.
  • edited May 2012
    You're misunderstanding me. I'm at a lost as to why LP can't render all collection, empty or populated in the default Rich Text view as with non-POCOs. The Order's Orderline data collection is there and populated, it's just not rendered at all. It's completely missing from the Rich Text output.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!