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.
From stackoverflow
-
Take a look here it seems that a provider with entity framework for DB2 exists.
jlembke : Unfortunately, due to a bad experience last year, EF has been ruled out for me. That's unfortunate, since EF is MSFT's future... -
table.AsEnumerable()... table.AsEnumerable().AsQueryable()...
However, you'd need to write your own translation (
Select
) to your type; and theIQueryable<T>
would still be using LINQ-to-Objects; the only purpose (in this scenario) of usingIQueryable<T>
overIEnumerable<T>
would be to use expressions for some other reason - perhaps for the dynamic LINQ library.MattSlay : How do you convert the other way? From IQueryable to a DataTable?Marc Gravell : The `IQueryable` is essentially a view over the data. The original `DataTable` still remains. To *create* a `DataTable`, perhaps see this: http://stackoverflow.com/questions/545328/datatable-to-generic-list-memory-leak
0 comments:
Post a Comment