views:

316

answers:

4

I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important property (don't really care about the parent). Is there a way to have it do lazy loading? Would that even fix it?

A: 

As far as I know LINQ to SQL does lazy loading by default. And even if it doesn't, I'm pretty sure the MS guys used some kind of identity map to ensure every record is loaded only once per DataContext.

Did you experience it getting stuck in a loop in practice?

Tobi
+1  A: 

In the designer, select a property on an entity in the diagram, and in the Code Generation section in the properties window, set Delay Loaded to True .

See this blog post.

Mark Cidade
A: 

Forgive me, but I am not seeing how to set the Delay Loading on an association.

Gabe Anzelini
A: 

This site is not good for my pre-existing biases, turns out this one was an ill-configured route not lazy/eager loading

Gabe Anzelini