c# - Get Specified row index of a column from a data table having values contained in a string -
i have data table having 2 columns select , value.
select value 0 213 0 314 0 282
i have integer array called ids={213,314} if values of ids occur in data table column "values" update "select" column 1. have using linq. please help
linq querying, not updating. have task in 2 steps. first querying rows should updated:
var rows = r in table.asenumerable() ids.contains(r.field<int>("value")) select r; // or lambda syntax // rows = table.asenumerable().where(r => ids.contains(r.field<int>("value")))
second part updating selected rows, not involve linq:
foreach(var row in rows) row.setfield("select", 1);
Comments
Post a Comment