c# Update object in List using Linq : <p>I have an viewmodel that has some relationships built.</p>

<pre><code>public class object()
{
    public int Id  {get; set;}
    public string Name {get;set;}
    public decimal Amount {get;set;}
}

public class myViewModel()
{
    public int Id {get;set;}
    public List&lt;object&gt; myObjects {get;set;}

}
</code></pre>

<p>What I would like to do is change the Amount for a specific myObject element given the object name.</p>

<pre><code>var query = new myViewModel();
</code></pre>

<p>Assume that I have populated data into the myObjects List.</p>

<pre><code>var record = query.myobjects.FirstOrDefault(x =&gt; x.Name = "Test");
</code></pre>

<p>Pulls the correct element from this list, but how to update the vale within the list is what I am stuck on. I have tried:</p>

<pre><code>query.myObject.FirstOrDefault(x =&gt; x.Name == "Test").Amount = 99;
</code></pre>

<p>and</p>

<pre><code>query.myObject.FirstOrDefault(x =&gt; x.Name == "Test") == record;
</code></pre>

<p>neither works.</p>
