title: How to get specific columns returned by stored procedure in variable/list using Entity Framework Core
body: <p>I want to get list of specific columns returned by stored procedure.In the result set two column names will be common and one column name will be dynamic.</p>
  
  <pre><code>ALTER PROC DBO.GETLANGUAGETRANSLATION(@LANGCODE VARCHAR(10))
  AS
  BEGIN
  DECLARE @QUERY NVARCHAR(255)
  SET @QUERY= N'SELECT RESOURCENAME,ENText,'+UPPER(@LANGCODE)+' INTO #TEMP FROM DBO.LANGUAGETRANSLATION SELECT * FROM #TEMP';
  EXEC(@QUERY);
  END
  </code></pre>
  
  <p>RESOURCENAME and ENText column will be same in output each time but based in input parameter third column name will vary.</p>
  
  <p>I am writing below code in C# using Entity Framework Core LINQ</p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;LanguageTranslation&gt;&gt; GetAsync(string langCode)
          {
              var context = new LQMSDbContext(AppConstants.DB_CONNECTION_STRING_KEY);
              try
              {
                  string query = "GetLanguageTranslation '" + langCode + "'";
                  var result = context.LanguageTranslation.FromSql(query).ToList();
                  var result1 = context.Database.ExecuteSqlCommand("GETLANGUAGETRANSLATION @p0", parameters: langCode );
              }
              catch(Exception ex)
              {
                  string a = ex.Message;
              }
  
  
              return await _dbSet
              .Where(x =&gt; x.Equals(langCode))
               .ToListAsync();
          }
  </code></pre>
  
  <p>I am trying to call stored procedure <strong>GETLANGUAGETRANSLATION</strong> using two different approaches. But both are failing with below error</p>
  
  <blockquote>
    <p>The required column 'ESText' was not present in the results of a
    'FromSql' operation</p>
  </blockquote>
  
  <p>Where ESText refers to the column which I am not returning from stored procedure but present in table.</p>
  
  <p>I want to store only few columns in result set in c# and not all.</p>
  
  <p>Can any body help me in this?</p>
  
  <p>NOTE : It works fine with <code>Select * from LanguageTranslation</code> query</p>