Wednesday, December 24, 2008

Small compile time error on LINQ (Could not find an implementation of the query pattern for source type . 'Select' not found)

A very verysilly error with LINQ. Happens when you try to use technology without learning it properly (obviously that's what happened to me).

The error you receive "Could not find an implementation of the query pattern for source type . 'Select' not found."

I was trying to use a LINQ query like this

var query = from w in TableName
      select w;

The above gave the error and I could not find a search result properly. Obviously people would have realized their mistakes, so wouldn't have posted it. 

The actual error is because we should not use the type name, rather we should be using the table instance variable in the datacontext. 

So after changing the query to

var query = from w in DataContext.TableInstanceName
      select w;

the problem is solved.

No comments: