用LINQ查询DataColumnCollection [英] Querying DataColumnCollection with LINQ
本文介绍了用LINQ查询DataColumnCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在myDataTable中的c中对DataTable的Columns属性执行一个简单的LINQ查询:
I'm trying to perform a simple LINQ query on the Columns property of a DataTable:
from c in myDataTable.Columns.AsQueryable()
select c.ColumnName
然而,我得到的是这样的:
However, what I get is this:
找不到源类型System.Linq.IQueryable的查询模式的实现。 '选择'未找到。考虑明确指定范围变量'c'的类型。
Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Select' not found. Consider explicitly specifying the type of the range variable 'c'.
如何使用LINQ获得DataColumnCollection玩得很好? p>
How can I get the DataColumnCollection to play nice with LINQ?
推荐答案
如何:
var x = from c in dt.Columns.Cast<DataColumn>()
select c.ColumnName;
这篇关于用LINQ查询DataColumnCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文