Question

Is there any way to analyze what entities have been loaded during one query request? Currently I'm using lazy loading and it has huge performance impact. So I would want to analyze query somehow and .Include all related objects.

Was it helpful?

Solution

You can handle ObjectMaterialized event of your context.

ObjectContext.ObjectMaterialized

http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.objectmaterialized%28v=vs.110%29.aspx

PS. If you work with DbContext, you need to retrieve ObjectContext from it first:

var context = new YourDbContext();
var adapter = (IObjectContextAdapter)context;
var objectContext = adapter.ObjectContext;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top