I'm trying to pre-compile queries in my Entity Framework application using my entities object.
I receive an error stating that There is no implicit reference conversion from myEntities to System.Data.Linq.DataContext.
An example of my compiled query is below. myEntities inherits 'ObjectContext', which is probably the root of the problem but I'm not sure why.
//Compiled Version
public static Func<myEntities, Users_GetUsersInRoleInputs, IQueryable<UserRole>> FilteredResult =
CompiledQuery.Compile<myEntities, Users_GetUsersInRoleInputs, IQueryable<UserRole>>(
(myEntities, Users_GetUsersInRoleInputs criteria) =>
(from t1 in dc.UserRoles
where (t1.Role_ID == criteria.RoleId)
select t1));
public class Users_GetUsersInRoleInputs
{
public int RoleId { get; set; }
public int CompanyId { get; set; }
}
Could anybody suggest why this might be and how I can use query compilation in my project?
(myEntities, Users_GetUsersInRoleInputs criteria)be(myEntities dc, Users_GetUsersInRoleInputs criteria)? - Jakub Januszkiewiczdc? Any why is myEntities a class name and a parameter name? - springy76