title: Unable to cast object of type 'System.Collections.Generic.List`1[]' to type 'System.Linq.IQueryable`1[]'
body: <p>I have got the following code in my unit test. But, it returns the error mentioned when run.</p>
  
  <pre><code>var leaveTypesList = new List&lt;LeaveType&gt;() { leaveType1, leaveType2, leaveType3 };
  var leaveTypesQueryable = leaveTypesList.AsQueryable();
  mockLeaveTypeRepository.Setup(r =&gt; r.GetLeaveTypes()).Returns(leaveTypesQueryable);
  var leaveTypeDtos = service.GetLeaveTypes();
  </code></pre>
  
  <p>The error is generated from the last line when the results are returned from the service.</p>
  
  <p>The service code for the <code>GetLeaveTypes</code> method listed below, which is a simple accessing of the repository.</p>
  
  <pre><code>    public IQueryable&lt;LeaveTypeDto&gt; GetLeaveTypes()
      {
          //return Mapper.Map&lt;IQueryable&lt;LeaveTypeDto&gt;&gt;(leaveTypeRepository.GetLeaveTypes());
          return leaveTypeRepository.GetLeaveTypes().ProjectTo&lt;LeaveTypeDto&gt;();
      }
  </code></pre>
  
  <p>The repository code is also a simple return of an <code>IQueryable</code> of leave types.</p>
  
  <pre><code>    public IQueryable&lt;LeaveType&gt; GetLeaveTypes()
      {
          return dbContext.LeaveType.Where(lt =&gt; lt.IsActive);
      }
  </code></pre>
  
  <p>Just cannot figure out what is wrong here. Any ideas?</p>