You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type I was copying looked innocuous enough being a POCO with an IEnumerable property. However these were part of an EF DbContext and at run time that property is lazy loaded so its a DbQuery - that means one massive object graph when recursively including all the private fields. I added some simple debug output to the InternalCopy method so you can see where its going - traversing into other entity types within the same DbContext, etc, etc.
(Note the number after the colon is the 'depth' of the object graph):
I have more output if its useful, I had a guard in there to stop when reaching a depth of 50, otherwise it goes on until the stack overflows.
I realize this maybe a similar outcome to the other stackoverflow issue open on here already, but at least people will note that there are a few different situations this could happen at runtime, without being able to necessarily predict it from the type as written in code.
The text was updated successfully, but these errors were encountered:
Hi,
The type I was copying looked innocuous enough being a POCO with an IEnumerable property. However these were part of an EF DbContext and at run time that property is lazy loaded so its a DbQuery - that means one massive object graph when recursively including all the private fields. I added some simple debug output to the InternalCopy method so you can see where its going - traversing into other entity types within the same DbContext, etc, etc.
(Note the number after the colon is the 'depth' of the object graph):
I have more output if its useful, I had a guard in there to stop when reaching a depth of 50, otherwise it goes on until the stack overflows.
I realize this maybe a similar outcome to the other stackoverflow issue open on here already, but at least people will note that there are a few different situations this could happen at runtime, without being able to necessarily predict it from the type as written in code.
The text was updated successfully, but these errors were encountered: