0

我有一个看起来像这样的查询:

var emp = (from activeWO in context.ActiveWOs
                               join activeWOUpdated in context.ActiveWOUpdatedTimes on activeWO.PW_ID equals activeWOUpdated.PW_ID into dj
                               from activeWOUpdated in dj.DefaultIfEmpty()
                               where activeWO.WODC.Contains("IDC") 
                    select new { activeWO.WO_Status,activeWO.PW_ID, activeWO.T_Number, activeWOUpdated.CALCActiveTimeSec });

我在 .dbml 文件中映射了两个表,但正如您在上面看到的,我不是只提取表类对象,而是从 2 个表中提取 3 列。

如何遍历结果emp

4

2 回答 2

3

如何遍历emp的结果?

最简单的是:

foreach(var item in emp)
{
  Console.WriteLine(item.WO_Status);
  //other properties
}
于 2013-05-22T09:09:00.613 回答
2

您可以使用foreach.

foreach (var item in emp)
{
    DoSomething(item.WO_Status);
}
于 2013-05-22T09:09:15.090 回答