title: Select only specific fields with Linq (EF core)
body: <p>I have a <code>DbContext</code> where I would like to run a query to return only specific columns, to avoid fetching all the data.<br>
  The problem is that I would like to specify the column names with a set of strings, and I would like to obtain an <code>IQueryable</code> of the original type, i.e. without constructing an anonymous type.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>// Install-Package Microsoft.AspNetCore.All
  // Install-Package Microsoft.EntityFrameworkCore
  
  using Microsoft.EntityFrameworkCore;
  using System;
  using System.Linq;
  
  public class Person {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  }
  
  public class TestContext : DbContext {
      public virtual DbSet&lt;Person&gt; Persons { get; set; }
      public TestContext(DbContextOptions&lt;TestContext&gt; options) : base(options) {
      }
  }
  
  class Program {
      static void Main(string[] args) {
  
          var builder = new DbContextOptionsBuilder&lt;TestContext&gt;();
          builder.UseInMemoryDatabase(Guid.NewGuid().ToString());
          var context = new TestContext(builder.Options);
  
          context.Persons.Add(new Person { FirstName = "John", LastName = "Doe" });
          context.SaveChanges();
  
          // How can I express this selecting columns with a set of strings? 
          IQueryable&lt;Person&gt; query = from p in context.Persons select new Person { FirstName = p.FirstName };
      }
  }
  </code></pre>
  
  <p>I would like to have something like this method:</p>
  
  <pre><code>static IQueryable&lt;Person&gt; GetPersons(TestContext context, params string[] fieldsToSelect) {
      // ...
  }
  </code></pre>
  
  <p>Is there a way I can do this?</p>