我正在使用visual studio 2013.这是一件奇怪的事情,但我找不到答案。我有以下LINQ查询
var tvAssingedJobs = dbEntities.Tv_ProductService
.Where(i => i.ServiceManagerId == userId
&& i.TechnicianId != null
&& (i.ProductServiceStatus != "C"
&& i.ProductServiceStatus != "QP")
);
foreach (var assingedJob in tvAssingedJobs)
{
var requision = assingedJob.Tv_SparePartsRequision
.FirstOrDefault(i => i.RecommendedUserId == userId
&& i.TechnicianId == assingedJob.TechnicianId
);
}
在这里我可以迭代,但我没有将它转换为列表。这个查询应该是这样的
var tvAssingedJobs = dbEntities.Tv_ProductService
.Where(i => i.ServiceManagerId == userId
&& i.TechnicianId != null
&& (i.ProductServiceStatus != "C"
&& i.ProductServiceStatus != "QP")
).ToList();
两者都很好。所以我的问题在哪?第一个查询可能会导致异常或将来在生产中产生一些性能问题吗?