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!
I found this detailed explaination of .NET project setting changes that must be updated when converting a project from an earlier version of .NET to 3.5 in order for the project and compiler to support Linq and the type inference feature associated with using Generics. In Project Settings, under the “Compile” tab, “Option infer” must be set to “On”. This will allow the compiler to infer the type of “someobject” created by any “dim someobject = [some expression]” This is why when I was using the debugger I wasn’t seeing the expected IEnumerable or able to use any of that interface’s associated members and properties. Because the project that the Linq query was in was an original 3.5 application the “Option infer” setting is on by default.