gpt4 book ai didi

.net - EnumerableRowCollection 类的用途是什么?

转载 作者:行者123 更新时间:2023-12-02 03:20:42 33 4
gpt4 key购买 nike

正如文档中所述 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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com