title: "Unable to create a constant value of type .. Only primitive types are supported ..'' in EF query?
body: <p>I have a work around for this issue, however I would appreciate it if someone could explain why this is happening and how I would design this for large datasets where my work around would not be viable.</p>
  
  <p>The full error is:
  Unable to create a constant value of type 'THPT_Razor.Models.WinType'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.</p>
  
  <p>and I am using EF v4.0.</p>
  
  <p>The commented lines are the offending code and the work around is the "For loop"</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>List&lt;WinType&gt; _atype = db.WinTypes.Where(wt =&gt; wt.IsWin == false).ToList();
  List&lt;WinType&gt; _wtype = db.WinTypes.Where(wt =&gt; wt.IsWin == true).ToList();
  string test = _wtype.Where(wt =&gt; wt.Value ==0).Select(wt =&gt; wt.Description).SingleOrDefault();
  List&lt;WinCheckDetails&gt; wcd = db.Wins.Include("UserProfiles").Where(w =&gt; w.venueLogId == logid).Select(w =&gt; new WinCheckDetails
  {
      //awarddesc = w.atypeid.HasValue ? _atype.Where( wt=&gt; wt.Value == w.atypeid).Select(wt =&gt; wt.Description).SingleOrDefault():string.Empty,
      //windesc = _wtype.Where(wt =&gt; wt.Value == w.typeid).Select(wt =&gt; wt.Description).Single(),
      atypeid = w.atypeid,
      typeid = w.typeid,
      WinId = w.WinId,
      other = w.other,
      posterid = w.posterid,
      confirmed = w.confirmed,
      posttime = w.posttime,
      game = w.game,
      playerid = w.UserProfile.PlayerID,
      firstname = w.UserProfile.FirstName,
      lastname = w.UserProfile.LastName,
      fullname = w.UserProfile.FirstName + " " + w.UserProfile.LastName
  }).OrderBy(o =&gt; o.game).ToList();
  foreach (WinCheckDetails wc in wcd)
  {
      wc.awarddesc = _atype.Where(wt =&gt; wt.Value == wc.atypeid).Select(wt =&gt; wt.Description).SingleOrDefault();
      wc.windesc = _wtype.Where(wt =&gt; wt.Value == wc.typeid).Select(wt =&gt; wt.Description).SingleOrDefault();
  }
  </code></pre>