Could not find an implementation of the query pattern
Is the tblPersoon
implementing IEnumerable<T>
? You may need to do it using:
var query = (from p in tblPersoon.Cast<Person>() select p).Single();
This kind of error (Could not find an implementation of the query pattern) usually occurs when:
- You are missing LINQ namespace usage (
using System.Linq
) - Type you are querying does not implement
IEnumerable<T>
Edit:
Apart from fact you query type (tblPersoon
) instead of property tblPersoons
, you also need an context instance (class that defines tblPersoons
property), like this:
public tblPersoon GetPersoonByID(string id)
{
var context = new DataClasses1DataContext();
var query = context.tblPersoons.Where(p => p.id == id).Single();
// ...
You may need to add a using
statement to the file. The default Silverlight class template doesn't include it:
using System.Linq;
Make sure these references are included:
- System.Data.Linq
- System.Data.Entity
Then add the using statement
using System.Linq;
You must have forgotten to add a using statement to the file like this:
using System.Linq;
I had a similar issue with generated strongly typed datasets, the full error message was:
Could not find an implementation of the query pattern for source type 'MyApp.InvcHeadDataTable'. 'Where' not found. Consider explicitly specifying the type of the range variable 'row'.
From my code:
var x =
from row in ds.InvcHead
where row.Company == Session.CompanyID
select row;
So I did as it suggested and explicitly specified the type:
var x =
from MyApp.InvcHeadRow row in ds.InvcHead
where row.Company == Session.CompanyID
select row;
Which worked a treat.