更新数据表中的多行不循环 [英] Update multiple rows in datatable without loop

查看:86
本文介绍了更新数据表中的多行不循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据表,在报名条件,并希望为多行一些处理更新列的值。

I have two datatable with conditions in application and want some processing for multiple rows to update column value.

例如:

我datatable1与10000行。我想通过datatable.select(条件)来过滤行,按条件,我想更新行值。

I have datatable1 with 10000 rows. I want to filter rows by datatable.select("condition") and as per condition, I want to update row values.

如果任何条件,我发现20行从数据表。我想在一杆,以更新的20条记录。没有任何环路。我有数据行数组这些值在确定时代更新。

If for any condition, I found 20 rows from datatable. I want to update those 20 records in one shot. Not in any loop. I have datarow array for those values to update in datable.

推荐答案

您可以尝试以下LINQ,

You can try out the following linq,

DataTable recTable = new DataTable();

// do stuff to populate table

recTable.Select(string.Format("[code] = '{0}'", someName)).ToList<DataRow>().ForEach(r => r["Color"] = colorValue);

您可以替换你的列和值在这里...

You can substitute your columns and values here...

这篇关于更新数据表中的多行不循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆