Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq Query not returning IEnumerable

Tags:

.net

vb.net

linq

I have the follow Linq query that is in a web application that was converted from .NET 1.1 to 3.5:

dim objListOfFilteredDataRows = from datarows as datarow in objDataSet.tables(0).rows _
                                where datarows("SomeColumn") = SomeValue

I have the exact same query in an application that was created using .NET 3.5 and the query returns an IEnumerable. However the query in the converted application is returning:

{Name = "WhereEnumerableIterator`1" FullName = "System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Data.DataRow, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}

**Edit: When I highlight the expression, the intellisense says that it doesn't know the type of objListOfFilteredDataRows and assumes its a type of "Object".

Why is the type not infered in the converted 1.1 application but is infered in the "native" 3.5?**

What am I missing here? How do I convert the "WhereEnumeratorIterator`1 to an IEnumerable? Thanks!

like image 662
Achilles Avatar asked Dec 13 '22 00:12

Achilles


1 Answers

No, you really did get an IEnumerable. It just happens to be implemented by a class inside the System.Linq.Enumerable namespace, a private class. That's unavoidable, there is no way to create an instance of an interface. Don't let the debugger info put you on the wrong track.

like image 105
Hans Passant Avatar answered Jan 01 '23 02:01

Hans Passant