title: Returning IEnumerable straight from database or using ToListAsync before
body: <p>How do the controllers work when giving them IEnumerable straight from the database? Which code is more correct and optimal? Let's assume that the database is very slow and there are other operations going on. </p>
  
  <p>This example is very simple so there might not be enough difference in execution times but i am trying to learn the best practices.</p>
  
  <h1> #1</h1>
  
  <pre><code>public Task&lt;Application[]&gt; Find(Expression&lt;Func&lt;Application, bool&gt;&gt; predicate)
  {
      return DatabaseContext.Applications
          .Where(predicate)
          .ToArrayAsync();
  }
  
  ...
  
  public Task&lt;Application[]&gt; Find(...)
  {
      return ApplicationService.Find(...);
  }
  </code></pre>
  
  <h1> #2</h1>
  
  <pre><code>public Task&lt;List&lt;Application&gt;&gt; Find(Expression&lt;Func&lt;Application, bool&gt;&gt; predicate)
  {
      return DatabaseContext.Applications
          .Where(predicate)
          .ToListAsync();
  }
  
  ...
  
  public async Task&lt;IActionResult&gt; Find(...)
  {
      var applications = await ApplicationService.Find(...)
      return Ok(applications);
  }
  </code></pre>
  
  <h1> #3</h1>
  
  <pre><code>public IEnumerable&lt;Application&gt; Find(Expression&lt;Func&lt;Application, bool&gt;&gt; predicate)
  {
      return DatabaseContext.Applications;
  }
  
  ...
  
  public IActionResult&lt;IEnumerable&lt;Application&gt;&gt; Find(...)
  {
      var applications = ApplicationService.Find(...);
      return Ok(applications);
  }
  </code></pre>