select all by where clause in linq

c#, linq, where-clause

Solution

`Where()` already returns all of the matching items. You don't need to add anything else. Try this:

foreach(var item in DB.Names.Where(x => x.age == 20 ))
{
   item.Name = " Mr " + item.Name;
}

Problem

Here is my code , ``` Name obj = new Name(); obj = DB.Names.Where(x => x.age == 20 ).SingleOrDefault(); ``` What I want to do is to update all the `Name` with `age=20` , ``` obj.Name = " Mr " + obj.Name ; DB.SubmitChanges(); ``` But `.SingleOrDefault()` can return only one value , I want to get all with `age=20` .

Original source