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'm only using LINQ to verify changes in the database, so I want it to act like a simple data access layer rather than a full ORM. To do this,I set set the data context's ObjectTrackingEnabled property to false to prevent LINQ from caching data. This works fine, except that it breaks associations between entities.
For instance, assume two tables WIDGET and CATEGORY, with a FK relationship between them. With object tracking enabled, widgetInstance.CATEGORY is correctly lazy-loaded. With object tracking disabled, nothing is lazy loaded and the CATEGORY property is always null.
How do I prevent LINQ from caching data, without also preventing lazy-loading?
UPDATE: Here's a link to the MSDN page referenced by the answer. Further research also turned up that I can use LoadWith to do eager loading of child data. In my case I just want the data, so eager loading is fine.