将数据集转换为IQueryable< T>或IEnumerable< T> [英] Convert Dataset to IQueryable<T> or IEnumerable<T>

查看:174
本文介绍了将数据集转换为IQueryable< T>或IEnumerable< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于没有Linq到DB2(在IBM!),我想在我的代码中处理IQueryables或IEnumerables,我将如何将DataTable转换为IQueryable?还是一个IEnumerable?



我有一个接口和类匹配数据表中的列...

  IQueryable< IMyData> GetAS400Data(.. parameters ..)
{
DataSet d = GetData();
...
//将d转换为IQueryable的一些代码< IMyData>
}

DataTable.Rows不支持.AsQueryable,因为MSFT打了它,所以我

解决方案

  table.AsEnumerable().. 。

table.AsEnumerable()。AsQueryable()...

但是,您需要将自己的翻译(选择)写入您的类型;而 IQueryable 仍将使用LINQ对对象;在 IEnumerable 中使用 IQueryable 的唯一目的(在这种情况下)将是使用表达式出于某些其他原因 - 也许对于动态LINQ库


Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable?

I have an interface and a class that matches the columns in the datatable...

IQueryable<IMyData> GetAS400Data(..parameters..)
{
    DataSet d = GetData();
    ...
    //Some code to convert d to IQueryable<IMyData>
}

DataTable.Rows does not support .AsQueryable, since MSFT yanked it, so I'm not sure what to do here.

解决方案

table.AsEnumerable()...

table.AsEnumerable().AsQueryable()...

However, you'd need to write your own translation (Select) to your type; and the IQueryable<T> would still be using LINQ-to-Objects; the only purpose (in this scenario) of using IQueryable<T> over IEnumerable<T> would be to use expressions for some other reason - perhaps for the dynamic LINQ library.

这篇关于将数据集转换为IQueryable&lt; T&gt;或IEnumerable&lt; T&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆