title: Only primitive types ('such as Int32, String, and Guid') are supported in this context
body: <p>I'm getting the following error:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>The error occurs on this line (towards the bottom):</p>
  
  <pre><code> var vla =  (from cir in phoenixEntities.ComponentInRoles
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>List&lt;ComponentRole&gt; roles;
  using (IMSMembershipEntities entities = new IMSMembershipEntities())
  {
      roles = (from role1 in entities.Roles
               select new ComponentRole{Name = role1.RoleName, RoleId = role1.RoleId} ).ToList();
  }
  
  List&lt;Components&gt; 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();
      }
  }
  </code></pre>