title: Get data from database table by string Name of table
body: <p>I have c# config where I have name of table or view and field from where I need to get data.</p>
  <p>Here is setting part</p>
  <pre><code>  new()
          {
              DisplayIndex = 1082,
              FieldNameDomain = nameof(VwScoringJobSupplier.SchemeIdentifications),
              Label = &quot;Identifications&quot;,
              DataType = &quot;string&quot;,
              Group = &quot;Attributes&quot;,
              IsAnalysisFilter = false,
              IsUseCaseFilter = false,
              FilterType = &quot;multiselect&quot;,
              IsAvailableForScoringAdmin = false,
              Source = &quot;VwScoringJobSuppliers&quot;
          },
  </code></pre>
  <p><code>FieldNameDomain</code> is name of field, <code>Source</code> is table or view</p>
  <p>I need to get name data from this view(table) from specific field in code like this</p>
  <pre><code>private async Task&lt;List&lt;OptionDto&gt;&gt; GetOptions(Guid jobId, string source, string field)
  {
     var options = await _dbContext.VwScoringJobSuppliers.Distinct().Where(x =&gt; x.JobId == jobId)
          .Select(x =&gt; x.State).ToListAsync();
  }
  </code></pre>
  <p>But table or view and field in select must come from strings <code>source</code> and <code>field</code></p>
  <p>How I can achieve this?</p>
  <p><strong>UPDATE</strong></p>
  <p>I can get dbSet like this</p>
  <pre><code>public static PropertyInfo GetDbSetProperty(Type typeOfEntity, ScoringDbContext context)
  {
      var genericDbSetType = typeof(DbSet&lt;&gt;);
      // typeof(DbSet&lt;User.Role&gt;);
      var entityDbSetType = genericDbSetType.MakeGenericType(typeOfEntity);
  
      // DbContext type
      var contextType = context.GetType();
  
      return contextType
          .GetProperties(BindingFlags.Public | BindingFlags.Instance)
          .Where(p =&gt; p.PropertyType == entityDbSetType)
          .FirstOrDefault();      
  }
  </code></pre>
  <p>But how I can then add it to</p>
  <pre><code>var blogs = context.Blogs
  .FromSqlRaw(&quot;SELECT {0} FROM dbo.{1}&quot;, source, field)
  .ToList();
  </code></pre>
  <p>?</p>