问题描述
使用LINQ查询数据表中返回以下错误:CS0117:'DataSet1.map数据表'不包含'AsEnumerable
Using linq to query a datatable returns the following error: CS0117: 'DataSet1.map DataTable' does not contain a definition for 'AsEnumerable'
项目包括System.Data.Datasetextensions参考。
Project includes reference for System.Data.Datasetextensions.
这里的code。
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Reflection;
using System.Data;
using System.Linq;
using System.Data.Linq;
using System.Data.Common;
using System.Data.DataSetExtensions;
using System.Linq.Expressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
var query1 = from mfg_nm in DataSet1.mapDataTable.AsEnumerable()
select mfg_nm;
}
运行它瓦特/ AsEnumerable()的结果。
running it w/out AsEnumerable() results in
var query1 = from mfg_nm in DataSet1.mapDataTable
select mfg_nm;
CS1660:无法转换拉姆达前pression键入字符串',因为它不是一个委托类型
CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type
在此先感谢您的帮助。
推荐答案
的method你想是在 System.Data这
命名空间,让使用
指令是好的,但也需要将 System.Data.DataSetExtensions
的组装的参考。您的确定的你已经有了引用作为的组装的参考?
The method you want is in the System.Data
namespace, so that using
directive is fine, but you also need a reference to the System.Data.DataSetExtensions
assembly. Are you sure you've got that reference as an assembly reference?
目前还不清楚为什么你已经有了一个用指令为 System.Data.DataSetExtensions
的命名的 - 不,不是引发错误?
It's not clear why you've got a using directive for a System.Data.DataSetExtensions
namespace - does that not raise an error?
什么是与确切的错误AsEnumerable()
打电话? (我很惊讶你与第二种形式得到的错误......这不是我所预期的误差。)
What is the exact error with the AsEnumerable()
call? (I'm surprised about the error you're getting with the second form... that's not the error I'd have expected.)
这篇关于数据表中不包含定义为AsEnumerable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!