title: How to build an empty generic IMongoQueryable<TEntity> type queryable object
body: <p>The method I use is returning a queryable object of type <code>IMongoQueryable&lt;TEntity&gt;</code>. Result of this method returns <code>default(IMongoQueryable&lt;TEntity&gt;)</code> when mongodb database throws an error. Instead of the default result, I want to replace that row with an empty queryable object, however MongoDb Linq library does not provide any.</p>
  
  <pre><code>//Sample of the code
  public IMongoQueryable&lt;TEntity&gt; AllQueryable&lt;TEntity&gt;(AggregateOptions options = null) where TEntity : Entity
  {
      try
      {
          return GetCollection&lt;TEntity&gt;().AsQueryable(options);
      }
      catch (Exception ex)
      {
          return default(IMongoQueryable&lt;TEntity&gt;);
      }
  }
  </code></pre>
  
  <p>So, how can I implement a custom type equivalent to the <code>Enumerable.Empty&lt;TEntity&gt;().AsQueryable()</code> or something like <code>IEnumerable&lt;TEntity&gt;().AsMongoQueryable()</code>?</p>
  
  <pre><code>//I need something like this
  public IMongoQueryable&lt;TEntity&gt; AllQueryable&lt;TEntity&gt;(AggregateOptions options = null) where TEntity : Entity
  {
      try
      {
          return GetCollection&lt;TEntity&gt;().AsQueryable(options);
      }
      catch (Exception ex)
      {
          return Enumerable.Empty&lt;TEntity&gt;().AsMongoQueryable();
      }
  }
  </code></pre>