title: LINQ related error "Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context
body: <p>I have some code that is selecting some values from my database. I have a IQueryable of requests, that contains a ICollection of rooms.</p>
  
  <p>I want to get a <code>List&lt;ICollection&lt;rooms&gt;&gt;</code>. I have tried the following and i recieve the above error. </p>
  
  <p>Any ideas??</p>
  
  <pre><code>public ActionResult _roomChecker(checkRooms JSONdata){
          var rooms = db.rooms.Include(r=&gt;r.building).Include(r=&gt;r.facilities);
          rooms = rooms.Where(r =&gt; r.capacity &gt;= JSONdata.capacity);
          if (JSONdata.type != "Any")
          {
              rooms = rooms.Where(r =&gt; r.roomType.Equals(JSONdata.type));
          }
          if (JSONdata.park != "Any")
          {
              rooms = rooms.Where(r =&gt; r.building.park.Equals(JSONdata.park));
          }
  
          if (JSONdata.facilities != null)
          {
              for (var i = 0; i &lt; JSONdata.facilities.Length; i++)
              {
                  rooms = rooms.Where(r =&gt; r.facilities.Any(f =&gt; f.facilityName.Equals(JSONdata.facilities[i])));
  
              }
          }
  
          var proposedRequest = db.requests.Include(r =&gt; r.rooms);
          proposedRequest = proposedRequest.Where(r=&gt;r.booked.Equals(1));
          proposedRequest = proposedRequest.Where(r =&gt; r.roundID.Equals(JSONdata.roundID));
          proposedRequest = proposedRequest.Where(r =&gt; r.day.Equals(JSONdata.day));
          proposedRequest = proposedRequest.Where(s =&gt; s.start &lt; JSONdata.start + JSONdata.length &amp;&amp; s.start + s.length &gt; JSONdata.start);
          int[] standardWeeks = new int[12] {1,2,3,4,5,6,7,8,9,10,11,12};
          var containsStandard = standardWeeks.Intersect(JSONdata.weeks);
          if (containsStandard.Count()!=0)
          {
              proposedRequest = proposedRequest.Where(r =&gt; r.weeks_request.Any(f =&gt; JSONdata.weeks.Contains(f.week)) || r.weeks.Equals(1));
          }
          else {
              proposedRequest = proposedRequest.Where(r =&gt; r.weeks_request.Any(f =&gt; JSONdata.weeks.Contains(f.week)));
          }
  
      //ERROR OCCURS ON THIS LINE BELOW
  
          List&lt;ICollection&lt;room&gt;&gt; bookedRooms = proposedRequest.Select(r =&gt; r.rooms).ToList();
  
  
          var deptRooms = db.rooms.Include(r =&gt; r.building).Include(r =&gt; r.facilities).Where(r =&gt; r.belongsTo.Equals(JSONdata.deptCode));
  
          roomCheckerObject suitableRooms = new roomCheckerObject();
          suitableRooms.code = JSONdata.deptCode;
          suitableRooms.roomNo = JSONdata.roomNo;
          suitableRooms.RequestNo = JSONdata.RequestNo;
          if(rooms.Count() &gt;0){
              suitableRooms.rooms = rooms.ToList();
              var buildings = rooms.Select(r =&gt; r.building).Distinct();
              suitableRooms.buildings = buildings.ToList();
          }
          if(bookedRooms.Count() &gt;0){
              suitableRooms.bookedRooms = bookedRooms;
          }
  
          if(deptRooms.Count() &gt;0){
              suitableRooms.deptRooms = deptRooms.ToList();
          }
          return PartialView(suitableRooms);}
  </code></pre>