Could not find an implementation of the query pattern
You may need to add a using
statement to the file. The default Silverlight class template doesn't include it:
using System.Linq;
You must have forgotten to add a using statement to the file like this:
using System.Linq;
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();
// ...
Make sure these references are included:
- System.Data.Linq
- System.Data.Entity
Then add the using statement
using System.Linq;