I am creating a complex structure with EF 4.1. A very simplified version looks like:
var top = from x in _context.top
select new TopView
{
field = top.field,
sub = ( from y in x.RelatedTable
select new SubView
{
subfield = y.subfield,
subsub = ( from z in y.AnotherRelatedTable
select new SubSubView
{
subsubfield = z.subsubfield
}
)
}
)
}
The viewmodels look like:
public class TopView {
string field { get; set; }
IEnumerable<SubView> sub { get; set; }
}
public class SubView {
string subfield { get; set; }
IEnumerable<SubSubView> sub { get; set; }
}
public class SubSubView {
string subsubfield { get; set; }
}
When I retrieve a TopView object in my controller (but don't access any of the properties, after a few seconds, my output shows:
The thread '<No Name>' (0x1b44) has exited with code 0 (0x0).
The thread '<No Name>' (0x1448) has exited with code 0 (0x0).
The thread '<No Name>' (0xf34) has exited with code 0 (0x0).
Now, when I remove the inner-most structure so that SubView looks like:
select new SubView
{
subfield = y.subfield
}
And re-run, I only get two of the exit messages.
Does each nested query run in its own thread? Are the messages something to worry about?