Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 .NET4
public static Func<ReviewEntities, int, IQueryable<ProjTeamMemberDetails>>
        GetTeamMembersByTeamId = CompiledQuery.Compile((ReviewEntities context, int teamId)
             => from tp in context.TeamPlayers
                join t in context.Teams on tp.TeamId equals t.ID
                join emp in context.Employees on tp.EmployeeId equals emp.ID
                where tp.TeamId == teamId && emp.IsActive == true
                orderby emp.JoiningDate
                select new ProjTeamMemberDetails
                {
                    EmployeeName = emp.FirstName + " " + emp.LastName,
                    Email = emp.Email,
                    Designation = context.Designations.FirstOrDefault(s => s.ID == emp.DesignationId).Name,
                    NIC = emp.NIC,
                    JoiningDate = emp.JoiningDate,
                    EmployeeID = emp.ID
               })
 
This is my code to create a compiled query for ADO.Net entity model framework. In the syntax "CompiledQuery.Complie((ReviewEntities", there is a strange error which say's
 
"The type 'ReviewEntities' cannot be used as type parameter 'TArg0' in the generic type or method 'System.Data.Linq.CompiledQuery.Compile(System.Linq.Expressions.Expression>)'. There is no implicit reference conversion from 'ReviewEntities' to 'System.Data.Linq.DataContext'."
 

I am unable to figure this out why this is creating error. It is not accepting first parameter that is DataContext.
 
Does Compiled query works in ADO.Net entity model or not?
 
Any help will be highly appreciated.
Posted 14-Sep-12 7:55am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You are probably using the CompiledQuery of System.Data.Linq. Use System.Data.Objects instead.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 205
1 Sergey Alexandrovich Kryukov 185
2 jlopez788 144
3 Rob Philpott 100
4 Prakriti Goyal 97
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,559
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 1 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100