2011-04-22 91 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