Is there any way to disable lazy loading for specific query on Entity Framework 6? I want to use it regularly, but sometimes I want to disable it. I\'m using virtual propert
Suppose you have this:
IOrderedQueryable<Private.Database.DailyItem> items;
using (var context = new Private.Database.PrivateDb())
{
context.Configuration.LazyLoadingEnabled = false;
items = context.DailyItem.OrderBy(c => c.sortOrder).OrderByDescending(c => c.isFavorite);
}
You'd still get lazy loading, despite the explicit setting of not to. The fix is easy, change it to this:
List<Private.Database.DailyItem> items;
using (var context = new Private.Database.PrivateDb())
{
// context.Configuration.LazyLoadingEnabled = false;
items = context.DailyItem.OrderBy(c => c.sortOrder).OrderByDescending(c => c.isFavorite).ToList();
}