The specified type member 'EntityKey' is not supported in LINQ to Entities
Posted
by user300992
on Stack Overflow
See other posts from Stack Overflow
or by user300992
Published on 2010-03-24T16:31:33Z
Indexed on
2010/03/24
16:43 UTC
Read the original article
Hit count: 578
I have 2 Entities "UserProfile" and "Agent", they are 1-many relationship. I want to do a query to get a list of Agents by giving the userProfileEntityKey. When I run it, I got this "The specified type member 'EntityKey' is not supported in LINQ to Entities" error.
public IQueryable<Agent> GetAgentListByUserProfile(EntityKey userProfileEntityKey)
{
ObjectQuery<Agent> agentObjects = this.DataContext.AgentSet;
IQueryable<Agent> resultQuery =
(from p in agentObjects
where p.UserProfile.EntityKey == userProfileEntityKey
select p);
return resultQuery;
}
So, what is the correct way to do this? Do I use p.UserProfile.UserId = UserId ? If that's the case, it's not conceptual anymore. Or should I write object query instead of LINQ query?
© Stack Overflow or respective owner