locked
Could not find an implementation of the query pattern for source type

    Question

  • EMMSDatabaseDataContext data = new EMMSDatabaseDataContext("Server=laver-chen;Database=EMMS;User=sa;Password=*****");
                var dst = from p in data.InspectionSafeties
                          select p;

     

    Error 1 Could not find an implementation of the query pattern for source type 'System.Data.Linq.Table<EMMS.Entity.InspectionSafety>'.  'Select' not found.  Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'? D:\wwwroot\EMMSDesktop\EMMS.Facade\Inspection\frmRoadSafety.cs 127 34 EMMS.Facade

     

    who help me?

    Monday, September 17, 2007 6:11 AM

Answers

  • You need to add

    using System.Linq;

    to your namespace imports. The compiler translates comprehension queries into lambda syntax, which require methods called "Where", "Select", "OrderBy", etc to be in scope in order to resolve. Importing the System.Linq namespace puts the Enumerable and Queryable classes in scope, which define these standard querying methods.

    Regards
    Joe
    Monday, September 17, 2007 9:01 AM

All replies

  • You need to add

    using System.Linq;

    to your namespace imports. The compiler translates comprehension queries into lambda syntax, which require methods called "Where", "Select", "OrderBy", etc to be in scope in order to resolve. Importing the System.Linq namespace puts the Enumerable and Queryable classes in scope, which define these standard querying methods.

    Regards
    Joe
    Monday, September 17, 2007 9:01 AM
  • For anyone who sees this error message but already has the correct using statements...I saw this error while trying to run Linq queries against a strongly typed data set with EnforceConstraints disabled.

     

    Setting EnforceConstraints back to True in the designer fixed it.

     

    Eric
    Tuesday, November 18, 2008 9:14 PM
  • I am using the AdventureWorks database

    I created a new LINQToSQL Class, dragged all of the Employee schema from the Server Explorer to the designer, and tried to reference the Employee Class in Code:

    var query =

    from employee in Employee

    I get the same error message:
    Could not find an implementation of the query pattern for source type 'Com.Tff.LINQToSQL.Employee'.  'Select' not found.

     

    Oddly, you can not specify the Select property in the Employee Data Class. - only has Insert, Delete, Update

    Tuesday, January 13, 2009 10:50 AM
  • Hi Jamie,

     

    It looks like you are querying against the type instead of an instantiated object.  Try something like this...

     

    AdventureWorksDataContext context = new AdventureWorksDataContext();

    var query =

        from employee in context.Employees

        select employee;

     

    In this example, AdventureWorksDataContext is the Name property in the LINQ to SQL designer (.dbml file).

     

    Eric

    Tuesday, January 13, 2009 4:04 PM
  • That's it

    Thanks

     

    Tuesday, January 13, 2009 5:14 PM
  • @Eric Lemmon:

    Thanks!  Your solution about EnforceConstraints on the typed dataset fixed my issue.

    Strangely, this error only started after I refactored my Typed Dataset into another library.

    - Zach Pennington
    Friday, January 15, 2010 9:14 PM
  • Hi Eric,

     

    I m querying against a instantiated object only and also have system.linq in using... I am also referring System.Core dll (using 4.0 framework)... still i m getting the same issue

     

    Please help

     

    Thanks & Regards,

    Taher N D

    TechDiary

     

    Thursday, May 26, 2011 9:00 AM
  • Thank's Joe.
    Friday, September 23, 2011 10:07 PM
  • Ohhh dude.. Hail You bro. Got tired of looking and trying. This is the solution I was looking for.
    Thursday, November 01, 2012 9:06 AM