title: How to return empty IQueryable in an async repository method
body: <p>Lets say I have a simple repository class, with one <code>GetByNames</code> method</p>
  
  <pre><code>public class MyRepo
  {
      private readonly MyDbContext _db;
  
      public MyRepo(MyDbContext db)
      {
          _db = db;
      }
  
      public IQueryable&lt;MyObject&gt; GetByNames(IList&lt;string&gt; names)
      {
          if (names== null || !names.Any())
          {
              return Enumerable.Empty&lt;MyObject&gt;().AsQueryable();
          }
  
          return _db.MyObjects.Where(a =&gt; names.Contains(a.Name));
      }
  }
  </code></pre>
  
  <p>Now when I use it with async EntityFramework <code>ToListAsync()</code> extension</p>
  
  <pre><code>var myObjects = awawit new MyRepo(_db).GetByNames(names).ToListAsync();
  </code></pre>
  
  <p>It will blow up if I pass in empty list or null because <code>Enumerable.Empty&lt;MyObject&gt;().AsQueryable()</code> does not implement <code>IDbAsyncEnumerable&lt;MyObject&gt;</code> interface.</p>
  
  <blockquote>
    <p>The source IQueryable doesn't implement IDbAsyncEnumerable. Only sources that implement IDbAsyncEnumerable can be used for Entity Framework asynchronous operations. For more details see <a href="http://go.microsoft.com/fwlink/?LinkId=287068" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=287068</a>.</p>
  </blockquote>
  
  <p>So my question is, how can I return an empty <code>IQueryable&lt;&gt;</code> that implements <code>IDbAsyncEnumerable</code>, without hitting the database?</p>