从DataTable插入到DataTable中

本文关键字:DataTable 插入 | 更新日期: 2023-09-27 17:51:22

我想在一些条件下将数据从一个DataTable插入到另一个DataTable。我发现这个链接很有用:http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/7a5d0f88-3e71-435a-ae3c-ff01d1ca22a2/但我无法将.ToList()用于我的查询。我得到以下错误:

'System.Data.EnumerableRowCollection<System.Data.DataRow>' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Data.EnumerableRowCollection<System.Data.DataRow>' could be found (are you missing a using directive or an assembly reference?)

有人能帮我解决这个问题吗?

我的查询:

(from crow in dtConfiguration.AsEnumerable()
                         where crow.Field<string>("FieldType") == "FL"
                         & crow.Field<string>("FieldName") != "DATEADDED"
                         & crow.Field<string>("FieldName") != "DATEMODIFIED"
                         select crow).ToList()

从DataTable插入到DataTable中

将以下语句添加到代码中:

using System.Linq;

我认为您需要一个System.Data.DataSetExtensions的参考C:'Program Files (x86)'Reference Assemblies'Microsoft'Framework.NETFramework'v4.0'System.Data.DataSetExtensions.dll