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?