Tôi nhận được lỗi sau:loại Chỉ nguyên thủy ('như Int32, String, và Guid') được hỗ trợ trong bối cảnh này
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.
Tôi hiểu tại sao lỗi xảy ra. Những gì tôi không hiểu là tại sao mã của tôi đang tạo ra lỗi. So sánh của tôi là chống lại các loại nguyên thủy. Tất cả các so sánh là Guid to Guid. Lỗi cụ thể nói rằng Guids là ok.
Lỗi này xảy ra trên đường dây này (hướng về phía dưới):
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();
}
}
Có một mối quan hệ giữa Foels và phoenixEntities? – Jethro