title: How to fill a property of an object from another list using LINQ
body: <p>I have 2 lists of objects.  One has values, the other has names and values.  I want to look up the values in the other list and write the result to pref.Name.  I know I can do this with a foreach, but I assume there's a good way to do it in LINQ.  Ideas?</p>
  
  <pre><code>public class Preference
      {
          public string Category { get; set; }
          public string Name { get; set; }
          public string ItemValue { get; set; }
          public int SortOrder { get; set; }
      }
  
  public class SAPReadOnlyItem
      {
          public string Category { get; set; }
          public string Name { get; set; }
          public string ItemValue { get; set; }
      }
  
      List&lt;Preference&gt; preferences = getExistingUserPreferences(UserID, ddlCategory.SelectedValue); //this list is just keys
      List&lt;SAPReadOnlyItem&gt; sapReadOnlyItems = getSAPReadOnlyItems(ddlCategory.SelectedValue); //this list is names and keys
  
      //i want to look up the name from sapReadOnly using the ID from preferences and write it into preferences[n].Name
  
      //this works, but I want to write it into preferences[n].Name
      var foobar = (from sap in sapReadOnlyItems
                    join pref in preferences 
                    on sap.ItemValue equals pref.ItemValue
                    select new { asdf = sap.Name }).FirstOrDefault(); //instead of "select new" I want to write it into preferences[n].Name
  </code></pre>