Can this extension be used with a linq to entities query?

Feb 11, 2014 at 4:53 PM
Can this extension be used with a linq to entities query?

I have a working linq query that sends the results to a viewmodel class but am unable to apply the pivot method to the results; the error I receive states that:

'System.Collections.Generic.IEnumerable<T>' does not contain a definition for 'TM' and no extension method 'TM' accepting a first argument of type 'System.Collections.Generic.IEnumerable<T>' could be found

I have tried casting the results of my query in several different ways with no success
Coordinator
Feb 17, 2014 at 2:17 PM
In order to use the pivot feature, you need to use the ToList/ToArray/AsEnumerable methods.
LinqLib is designed to work on in memory objects (Linq to objects). In order to work with entity Framework or, it needs to translate the pivot function into a SQL statement which it does not.

Just add a ToList() to the end of your statement and than you can pivot the results as needed.

HTH

Amir