What is the most succint/simple way of updating a single property of a specific item within a collection using LINQ?
For example if I have a List of the following:
public class Ticket
{
public string Name { get; set; }
public string Code { get; set; }
public bool Selected { get; set; }
}
How can I use LINQ to update the "Selected" property of a Ticket item wheres its "Name" property has the value of "Beach". In SQL it would be:
UPDATE Tickets SET Selected = true WHERE Name = 'Beach'
I thought I was on the right track with this...
tickets.Select(x => { x.Selected = true; return x; }).ToList().Where(x => x.Name == "Beach");