Using Castle Windsor to manage Linq to SQL DataContext with lifetime of per web:
Component.For<MyDataContext>()
.ImplementedBy<MyDataContext>()
.LifestylePerWebRequest()
Problem is that I need to eager load some child collections and from time to time and cannot set the DataLoadOptions once the context has returned some results.
Setting load options is not allowed after results have been returned from a query.
Only option I can see is to set the options in the constructor:
public SomeController(MyDataContext context)
{
_context = context;
var options = new DataLoadOptions();
options.LoadWith<MyEntity>(x => x.Children);
_context.LoadOptions = options;
}
Any tips or advice on how to handle this situation greatly appreciated.