- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正如文档中所述 DataTable.AsEnumerable()
Returns an IEnumerable<T> object, where the generic parameter T is DataRow. This object can be used in a LINQ expression or method query.
但是AsEnumerable()
的返回类型不只是一个 IEnumerable<DataRow>
它也是一个 EnumerableRowCollection<DataRow>
为什么会有这种类型?它比说 DataTable.Rows.Cast<DataRow>()
有什么好处?它只提供一个 IEnumerable<DataRow>
?
最佳答案
来自 EnumerableRowCollection<TRow>
的页面那里有几种扩展方法,它们专门接受并返回 EnumerableRowCollection<TRow>
由此我假设有DataTable
仅使用 IEnumerable<DataRow>
时无法使用这些方法的特定实现
我也找到了这个blog post哪个州
In order for LinqDataView to work without using IQueryable (which we didn’t want to do for performance reasons), we have to hold on to the implementation class. As long as are working with a EnumerableRowCollection instance instead of a “something” which implements IEnumerable we can capture each LINQ operator into a state bag which allows us to recreate the effects of the LINQ query in a DataView.
我原以为 LINQ-To-Objects 涵盖了 LINQ 与 IEnumerables 的任何使用以及任何其他意味着使用 IQueryables 的内容,但我想事实并非如此。 IQueryable<T>
还实现了 IEnumerable<T>
但它比 DataRowCollection<TRow>
有更多 IQueryable 特定扩展方法可用
关于.net - EnumerableRowCollection<TRow> 类的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33654910/
正如文档中所述 DataTable.AsEnumerable() Returns an IEnumerable object, where the generic parameter T is Dat
这个有效: from x in table.AsEnumerable() where x.Field("something") == "value" select x.Field("decimalfi
我试图在一个函数中返回这个集合: List codes = ( from q in Data.AsEnumerable() select q.Field("START") ); return code
我有一个类R具有一些属性。 同样我有一个DataTable dt列与类的属性完全相同 R 我正在尝试创建 2 个不同的 DataTables从上面说DataTable dt基于 dt 的其中一列的条件
我正在尝试使用下面的代码来存储值,但它给我错误。 int dqty= Convert.ToInt32(from row in result.AsEnumerable() where row.Fiel
我是一名优秀的程序员,十分优秀!