Reputation: 1084
My datatable looks like
Id|Name|Status
1 |a |1
2 |b |1
3 |c |1
4 |d |1
and dictionary have key value pair like
key Value
2 y
4 Y
dictionary will contain only those keys whose status need to be updated
and the updated datatable that i need is something like below,
Id|Name|Status
1 |a |1
2 |b |0
3 |c |1
4 |d |0
So is this achievable in c# using linq.
Upvotes: 1
Views: 819
Reputation: 1323
I was able to get this to work, if I understand what you're wanting to do correctly. Someone else may have a more elegant solution, but this is working...
oDt.Select(string.Format("[Id] in ({0})",string.Join(",",oDict.Select(x=>x.Key)))).ToList<DataRow>().ForEach(r=>r["Status"] = 0);
where oDt is your datatable, and oDict is your dictionary.
Upvotes: 1