是否有可能下面的代碼轉換到LINQ,它看起來像多一點很好轉換到LINQ
foreach (var entry in bottleneck.Item2)
{
if(entry.ChangeoverTime > 0)
{
avarangechangeOverTimes += entry.ChangeoverTime;
++counter;
}
if (entry.ChangeoverTime > maxchangeOverTimes)
{
maxchangeOverTimes = entry.ChangeoverTime;
}
changeovertime.ChangeoverTimes.Add
(
new ChangeOverDateValue
{
ChangeoverValue = entry.ChangeoverTime,
Color = ChangeOverTimeToColor(entry.ChangeoverTime),
StartTime = entry.StartTime
}
);
}
Depends中在什麼瓶頸上。它將始終迭代,但如果瓶頸是dbcontext,那麼linq語句將被轉換爲sql。除此之外,那+1最好的解決方案^^ – Frederiek 2012-03-28 11:53:11