I have an viewmodel that has some relationships built.
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<object> myObjects {get;set;}
}
What I would like to do is change the Amount for a specific myObject element given the object name.
var query = new myViewModel();
Assume that I have populated data into the myObjects List.
var record = query.myobjects.FirstOrDefault(x => x.Name = "Test");
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:
query.myObject.FirstOrDefault(x => x.Name == "Test").Amount = 99;
and
query.myObject.FirstOrDefault(x => x.Name == "Test") == record;
neither works.