我正在使用EF 4.1创建一个复杂的结构。非常简化的版本如下:
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
}
)
}
)
}
视图模型看起来像:
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; }
}
当我在控制器中检索TopView对象时(但不访问任何属性,几秒钟后,我的输出显示:
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).
现在,当我删除最内层的结构时,SubView看起来像:
select new SubView
{
subfield = y.subfield
}
重新运行,我只收到两条退出消息。
每个嵌套查询是否都在自己的线程中运行?这些消息是否值得担心?