Reputation: 21
dtbl isn't a strongly typed DataTable, but all these nonetheless work fine (so namespaces and references appear to be ok)
EnumerableRowCollection<DataRow> a = dtbl.AsEnumerable();
DataView b = dtbl.AsDataView();
IEnumerable<DataRow> c = from y in dtbl.AsEnumerable() select y;
however, both these yield: "Cannot implicitly convert IEnumerable to EnumerableRowCollection"
EnumerableRowCollection<DataRow> d = from y in dtbl.AsEnumerable() select y;
EnumerableRowCollection<DataRow> e = dtbl.AsEnumerable().Select(y=>y);
the error makes sense, but queries returning EnumerableRowCollection are shown in MSDN example http://msdn.microsoft.com/en-us/library/bb669080(v=vs.110).aspx and here on stackoverflow without apparent hiccup
this is a showstopper, so a solution would be very welcome, as I need to get to:
DataView view = (query performing filter and sort on dtbl).AsDataView();
Upvotes: 1
Views: 480
Reputation: 109261
I can't reproduce this with VS 2012 and .Net 4.5, but a work-around could be to bypass the syntactic sugar of extension methods and use the Select
method directly off the static class in which it is defined:
EnumerableRowCollectionExtensions.Select(dtbl.AsEnumerable(), d => d)
See EnumerableRowCollectionExtensions Class.
Upvotes: 1
Reputation: 21
SOLVED: it was an interfering extension method; I defined a list of "pass-though" extensions (Select, OrderBy, etc) to allow functions in other source files to avoid "using System.Linq", as well as allowing all Linq calls to be quickly found by reference.
Turns out there are undocumented (and apparently inaccessible) versions of the extension methods like EnumerableRowCollection.Select<>() that get hidden by the pass-throughs, and that are defined in an extension class that so far I can't find.
Anyway, I can get there from here by either finding the extension class, or yanking the pass-throughs.
Upvotes: 0