Could Not Find an Implementation of the Query Pattern

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();
// ...

Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'

you will need to add reference to System.Data.Linq

System.Data.Linq is LINQ-SQL specific (DataContext, etc)

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Linq;
using System.Linq;

public static class QueryClass
{
public static void Query()
{
using (var context = new MyDbEntities())
{

IQueryable<MyTable> qTable= from t in context.Tables
select t; // can you confirm if your context has Tables or MyTables?
Console.WriteLine("Table Names:");
foreach (var t in qTable)
{
Console.WriteLine(t.Name);//put the relevant property instead of Name
}
}
}
}

Could not find an implementation of the query 'Select' not found

I think your error is that you try to select something from .Database directly, not from the table. Instead of this code:

from UiType in db.Database

try out something like this:

from UiType in db.UiTypes
select UiType.AdvancedUi;

This should work as the table UiTypes will implemet the IEnumerable interface.

You should put your table name after the in keyword.

UiType is just a placeholder, and can be anything you want. Please, pay attention to the select clause - you must use the placeholder there, not the table name.



Related Topics



Leave a reply



Submit