I'm getting the following error:
Unable to create a constant value of type 'Phoenix.Intranet.Web.ClientSettings.ComponentRole'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
I understand why the error occurs. What I don't understand is why my code is creating the error. My comparisons are against primitive types. All the comparisons are Guid to Guid. The error specifically states that Guids are ok.
The error occurs on this line (towards the bottom):
var vla = (from cir in phoenixEntities.ComponentInRoles
Code:
List<ComponentRole> roles;
using (IMSMembershipEntities entities = new IMSMembershipEntities())
{
roles = (from role1 in entities.Roles
select new ComponentRole{Name = role1.RoleName, RoleId = role1.RoleId} ).ToList();
}
List<Components> componentInRoles;
using (PhoenixEntities phoenixEntities = new PhoenixEntities())
{
phoenixEntities.ContextOptions.LazyLoadingEnabled = false;
componentInRoles = (from component in phoenixEntities.Components
select new Components{Name = component.Name,
ComponentId = component.ComponentId,
//InRoles = (from componentInRole in phoenixEntities.ComponentInRoles
// join role in roles on componentInRole.RoleId equals role.RoleId
// where componentInRole.ComponentId == component.ComponentId
// select new ComponentRole{RoleId = role.RoleId, Name = role.Name})
}
).ToList();
foreach (Components cmpent in componentInRoles)
{
Components cmpent1 = cmpent;
//cmpent.InRoles =
var vla = (from cir in phoenixEntities.ComponentInRoles
join role in roles on cir.RoleId equals role.RoleId
where cir.ComponentId == cmpent1.ComponentId
select role).ToList();
}
}