title: Fetching only required columns from table using LINQ to modify and save record gives a typical error
body: <p>So what I was trying was to fetch only those columns from table which has to be updated and I tried it as below:</p>
  
  <pre><code>var user = (from u in context.tbl_user where u.e_Id == model.Id select 
             new { u.first_name, u.last_name, u.role, u.email, u.account_locked })
             .FirstOrDefault();
  </code></pre>
  
  <p>But when I tried to assign new value to the fetched data as below</p>
  
  <pre><code>user.first_name = model.FirstName;
  </code></pre>
  
  <p>I saw below error getting displayed</p>
  
  <p><a href="https://i.stack.imgur.com/S2xHM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S2xHM.png" alt="Error Image"></a></p>
  
  <blockquote>
    <p><strong>Property or indexer 'anonymous type: string first_name, string
    last_name, string role, string email, bool account_locked.first_name'
    cannot be assigned to -- it is read only</strong></p>
  </blockquote>
  
  <p>But when I retrieved all the values from table without filtering as below it worked fine.</p>
  
  <pre><code>var user = (from u in context.tbl_user where u.e_Id == model.Id select u).FirstOrDefault();
  </code></pre>
  
  <p>Why it doesn't work for first query. I've read in many sites that it is good to retrieve only required properties from database in terms of performance and security. But I am really not able to understand what's wrong with the first approach I opted. Any explanations are much appreciated.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Are there any other ways to fetch only required column and update them and store them back?</p>