Is there a way to disable LINQ\'s object tracking features, without also disabling lazy-loaded child associations?
I\'m using LINQ2SQL in a set of integration tests. I\'
According to MSDN:
Deferred loading requires object tracking. Only the following three modes are valid:
ObjectTrackingEnabled = false. DeferredLoadingEnabled is ignored and inferred to be false. This behavior corresponds to a read-only DataContext.
ObjectTrackingEnabled = true. DeferredLoadingEnabled = false. This situation corresponds to a DataContext that allows users to load an object graph by using LoadWith directives, but it does not enable deferred loading.
Both are set to true. This is the default.
You either have to enable object tracking and detach entities (which is doable since you're running tests, I guess, otherwise it pretty much troublesome to detach every single entity of another entity of...), or use DataLoadOptions.LoadWith() or AssociateWith() to eager-load the relationships.