Can anybody help me with this: I want select all records from datata开发者_运维问答ble which have for example sid=123 and after that save they with sid=456.
How can I do this with LINQ?
items.Where(i=>i.sid == 123).ToList().ForEach(i=>i.sid = 456);
or rather use normal foreach
foreach (var item in items.Where(i=>i.sid == 123))
{
item.sid = 456
}
edit: sorry, i didn't notice that datatable. you can't query rows on datatable directly (they don't impletement IEnumerable)
but you can do something like this
using System.Data; //System.Data.DataSetExtensions.dll
datatable.AsEnumerable().Where(row=>row.Field<int>("sid") == 1234)
精彩评论