title: Mapster - Dynamic property selection or ignore
body: <p>I have a business need to dynamically select ONLY the properties of a given model that are specified, similar to an OData select clause. I am currently using Mapster's ProjectToType functionality to populate view models from EF Core entities.</p>
  <p>Is there any way to tell Mapster to only select a given list of properties in the query that it generates? Or a way to take the full model mapping, and change mappings at runtime in an instance of TypeAdapterConfig to ignore properties that aren't in a given list of properties?</p>
  <p>The end solution needs to be generic and work with navigation properties, because it will be applied to all of our entities in the database. We also used DynamicLinq in some cases, not sure if that can be used on top of Mapsters ProjectToType functionality.</p>
  <p>Example:</p>
  <p>Entities  (Some properties omitted for length):</p>
  <pre><code>namespace DataAccess.Entities
  {
      public class Series
      {
          public Guid Id { get; set; }
          public string Description { get; set; }
          public long? StackRank { get; set; }
          public string EntityId { get; set; }
          // Other properties
      }
  
      public class Model
      {
          public Guid Id { get; set; }
          public string Description { get; set; }
          public string EntityId { get; set; }
          public long? StackRank { get; set; }
          public Guid SeriesId { get; set; }
          
          public virtual Series Series { get; set; }
          
          // Other properties
  
      }
  }
  </code></pre>
  <p>View Models (Some properties omitted for length):</p>
  <pre><code>namespace Models
  {
      public class Model
      {
          public Guid Id { get; set; }
          public string Description { get; set; }
          public string EntityId { get; set; }
          public long? StackRank { get; set; }
          public Guid SeriesId { get; set; }
          
          public virtual Series Series { get; set; }
          
          // Other properties
      }
      
      public class Series
      {
          public Guid Id { get; set; }
          public string Description { get; set; }
          public long? StackRank { get; set; }
          public string EntityId { get; set; }
          // Other properties
      }
  }
  </code></pre>
  <p>Given a rest call to get a list of all Model view models, with this list of properties to include:</p>
  <pre><code>var properties = new List&lt;string&gt; {
  &quot;Id&quot;,
  &quot;EntityId&quot;
  &quot;Description&quot;,
  &quot;Series.Id&quot;,
  &quot;Series.Description&quot;,
  &quot;Series.EntityId&quot;
  }
  </code></pre>
  <p>The results would return some type of dictionary, dynamic, or anonymous object that contained ONLY these properties, and the other properties would not even be included in the final select of the SQL query that gets created.</p>