title: LINQ - Cannot implicitly convert type 'AnonymousType#1' to 'string'
body: <p>i have the following code that i need to modify with an if statement to say that if something that make result this, or else make it that. here is what i have now:</p>
  
  <pre><code> var result = (from fs in ctx.datFiles
                        where fs.File_ID == fID
                        select new
                        {
                            LastName = fs.datClaim.LastName,
                            FirstName = fs.datClaim.FirstName,
                        }).FirstOrDefault();
  
  
  
      DetailsModelView dmv = new DetailsModelView
      {
          ClaimID = result.ClaimID,
          LastName = result.LastName,
          FirstName = result.FirstName,
  
      };
  </code></pre>
  
  <p>i want to do something like:</p>
  
  <pre><code>var result =""
  
  if (something)
  {
  result = (from fs in ctx.datFiles
                            where fs.File_ID == fID
                            select new
                            {
                                LastName = fs.datClaim.LastName,
                                FirstName = fs.datClaim.FirstName,
                            }).FirstOrDefault();
  
  }
  else
  {
  result = (from fs in ctx.datFiles
                            where fs.File_ID == 5
                            select new
                            {
                                LastName = fs.datClaim.LastName,
                                FirstName = fs.datClaim.FirstName,
                            }).FirstOrDefault();
  }
  
          DetailsModelView dmv = new DetailsModelView
          {
              ClaimID = result.ClaimID,
              LastName = result.LastName,
              FirstName = result.FirstName,
  
          };
  </code></pre>
  
  <p>but i keep getting the following error: Cannot implicitly convert type 'AnonymousType#1' to 'string' when i try to create "result" outside of the LINQ statement. </p>
  
  <p>What do i need to declare result as to make it work, instead of string?</p>
  
  <p>this was just a simple example, my query gets a lot more complicated on the "else" then just the ID change.</p>