Linq Error - "NotSupportedException: Unsupported Overload Used for Select Request Operator"

I have the following Linq query:

var tmp = from container in Container join containerType in ContainerType on container.ContainerType equals containerType where containerType.ContainerTypeID == 2 select new { ContainerID = container.ContainerID, TypeID = container.ContainerTypeID}; var results = tmp.Select((row, index) => new { row.ContainerID, row.TypeID, ContainerIndex = index }) 

Like everyone else, this works great. If I add the following to see the results in LinqPad, I get the error described in the header of this post:

 results.Dump(); 

This error is not a LinqPad error, it comes from Linq, and I don’t understand what that means.

Thanks.

+7
linq
source share
1 answer

Well, I did not understand that Container was the LINQ to SQL data source for starters. In fact, it cannot convert the second projector to SQL.

So, you want to make exactly this bit in .NET instead - you can force it to use Enumerable.Select with AsEnumerable :

 var results = tmp.AsEnumerable() .Select((row, index) => new { row.ContainerID, row.TypeID, ContainerIndex = index }); 
+15
source share

All Articles