开发者

Iterate data in anonymous variable

I have a DataTable containing some data, and I am going to fetch some data from it using Linq to datatable.

The query looks like this:

开发者_C百科
var requiredData=dt.AsEnumerable()
  .Where(row => row.Field<byte>("id") == 1)
  .Select(x=> {
    id = x.Field<int>("id"),
    YYYYY = x.Field<string>("ColumnName2"),
    ZZZZZ = x.Field<string>("ColumnName3")
  }
);

Now, Please how do I iterate-through "requiredData"?


You could use a foreach loop:

foreach (var item in requiredData)
{
    // TODO: use item.id, item.YYYYY and item.ZZZZZ here
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜