FYI, there's a bug in the RTM LinqDataSource where child tables aren't loaded unless you have updating or deleting enabled. Apparently if you have a LinqDataSource that doesn't have updates or deleted enabled, ObjectTracking is turned off (for performance reason), but deferred queries (e.g. queries to pull back child rows) aren't executed.
So statements like
<%# Eval("ChildTable.ChildTableField") %>
in your ListView, etc. won't work.
Annoying, needless to say. But at least now I know.
So, there are a few options:
public void OnContextCreated(object sender, LinqDataSourceContextEventArgs e) { ((DataContext)e.ObjectInstance).ObjectTrackingEnabled = true; } OR public void OnContextCreated(object sender, LinqDataSourceContextEventArgs e) { var dataLoadOptions = new DataLoadOptions(); dataLoadOptions.LoadWith<MyTable>(t => t.ChildTable); ((DataContext)e.ObjectInstance).LoadOptions = dataLoadOptions; }
Setting LoadOptions is normally the best approach for performance.
Remember Me
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Ben Strackany
E-mail