2011-04-22 92 views
1

我想从一个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?)

可能有的请大家帮我解决这个问题?

PS:我的查询:

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

你有'使用System.Linq的;'? – Stecya 2011-04-22 10:27:35

+0

您可能需要使用System.Linq的命名空间.. – 2011-04-22 10:27:51

回答

8

将以下语句添加到您的代码:

using System.Linq; 
4

我认为你需要commenly发现在 ÇSystem.Data.DataSetExtensions参考: \程序文件(x86)\参考大会\微软\ Framework.NETFramework \ V4.0 \ System.Data.DataSetExtensions.dll

+0

对不起,我听不懂你的意思!我问这个问题,3个月前与它已经解决了。 – NaveenBhat 2011-08-02 08:07:58