I have this table structure ->
SecretAnswer -> *1 -> SecretQuestion
Naturally when I do the query for SecretQuestion (no DataLoadOptions) it returns back the object with associated Sec开发者_如何学CretAnswers loaded for it as well (which I would think should be lazy loaded instead). I only want my SecretAnswer, I don't want the linq to load the collection of SecretAnswer and nothing else. How to make it happen?
Edit: How do I tell linq to return nulls for the entity set collection?
By default LINQ to SQL does delay the loading of objects from associated tables. It might appear that it doesn't because if you try to view the properties of lazy loaded objects in the debugger it can trigger fetching the values.
See this page for more information about activating and deactivating delay loading.
Here is what I ended up doing to exclude the associations loaded explicitly:
var secretQuestions = SqaManager.GetSecretQuestions();
secretQuestions.ForEach(q=>q.SecretAnsers = null);
精彩评论