In my silverlight application I am trying to create a database connection using LINQ.
First I add a new LINQ to SQL class, and drag my table called "tblPersoon" into it.
Then in my service file I try to execute the following query:
[OperationContract]
public tblPersoon GetPersoonByID(string id)
{
var query = (from p in tblPersoon where p.id == id select p).Single();
But at tblPersoon it gives me the following error.
Could not find an implementation of the query pattern for source type
'SilverlightApplication1.Web.tblPersoon'. 'Where' not found.
And even when I try the following:
var query = (from p in tblPersoon select p).Single();
It gives me an error saying 'Select' not found!
Code for the generated class for my table can be found here: http://pastebin.com/edx3XRhi
What is causing this and how would I possibly solve this?
Thank you.
Best Answer
Is the
tblPersoon
implementingIEnumerable<T>
? You may need to do it using:This kind of error (Could not find an implementation of the query pattern) usually occurs when:
using System.Linq
)IEnumerable<T>
Edit:
Apart from fact you query type (
tblPersoon
) instead of propertytblPersoons
, you also need an context instance (class that definestblPersoons
property), like this: