I am using visual studio 2013 .Here a strange thing happen but i cannot find the answer .I have following LINQ query
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
);
}
Here i can iterate but i did not convert it to list .Is this query supposed to be like this
var tvAssingedJobs = dbEntities.Tv_ProductService
.Where(i => i.ServiceManagerId == userId
&& i.TechnicianId != null
&& (i.ProductServiceStatus != "C"
&& i.ProductServiceStatus != "QP")
).ToList();
Both working fine.So my question in which to use ? Is first query may cause exception or create some performance issue in production in future ?