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
Generic Base Class for Winform Usercontrol
Synchronized Scrolling of Two Scrollviewers Whenever Any One Is Scrolled in Wpf
ASP.NET Identity - Multiple Object Sets Per Type Are Not Supported
What Is the Easiest Way to Subtract Time in C#
How to Detect If Type Is Another Generic Type
Algorithm to Find Which Numbers from a List of Size N Sum to Another Number
How to Update Textbox on Gui from Another Thread
What Is the Max Limit of Data into List<String> in C#
String Interning in .Net Framework - What Are the Benefits and When to Use Interning
How to Get Files in a Relative Path in C#
How to Perform a Unicode Aware Character by Character Comparison
C# Testing to See If a String Is an Integer
How to Get the Member to Which My Custom Attribute Was Applied