title: Need help converting CASE statement in LINQ
body: <p>I am trying to convert a few CASE statements in a SQL query to LINQ.</p>
  <p>Here is part of the SQL statement with the CASE statements:</p>
  <pre><code>         SELECT
           dt.DisplayText,
        CASE WHEN fsh.FieldName = 'SiteId' THEN 'SiteName' ELSE fsh.FieldName END as FieldName,
           fsh.FieldName,
           fsh.[Action],
        CASE WHEN fsh.FieldName = 'SiteId' THEN so.SiteName ELSE fsh.OldValue END as OldValue, 
        CASE WHEN fsh.FieldName = 'SiteId' THEN sn.SiteName ELSE fsh.NewValue END as NewValue,
           fsh.OldValue,
           fsh.NewValue,
           u.UserName,
           fsh.ModifiedDate,
           fs.ProgramGroupYear,
           fs.CustomerId
  </code></pre>
  <p>Part of LINQ with the CASE statements. I put the CASE statements in here as placeholders. Obviously those statements in LINQ won't work.</p>
  <pre><code>  public async Task&lt;IEnumerable&lt;HistoryRecord&gt;&gt; GetHistoryRecords(int documentTypeId, int 
    programGroupYear, int customerId, DateTime? from, DateTime? to, CancellationToken 
    cancellationToken)
  {
      Guard.Zero(documentTypeId, nameof(documentTypeId));
  
      var query = _context.FileStoreHistories
      .Join(_context.FileStores, fsh =&gt; fsh.FileStoreId, fs =&gt; fs.FileStoreId,
                          (fsh, fs) =&gt; new
                          {
                              fs.CustomerId,
                              fs.ProgramGroupYear,
                              fs.DisplayText,
                              **CASE WHEN fsh.FieldName = 'SiteId' 
                    THEN 'SiteName' ELSE 
                      fsh.FieldName END as FieldName,**
                              fsh.FieldName,
                              fsh.Action,
                              *****CASE WHEN fsh.FieldName = 'SiteId' 
                    THEN so.SiteName ELSE 
                      fsh.OldValue END as OldValue, 
                              CASE WHEN fsh.FieldName = 'SiteId' THEN 
                      sn.SiteName ELSE 
                      fsh.NewValue END as NewValue,*****
                              fsh.OldValue,
                              fsh.NewValue,
                              fsh.ModifiedBy,
                              fsh.ModifiedDate,
                              fs.DocumentTypeId
                          }
                     ....
  </code></pre>
  <p>If this is not enough code I can provide more. I appreciate any assistance I can get. Thank you</p>