Click here to Skip to main content
15,672,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have list having all information of employee eg
List<employee> lstEmployee = Employee.GetAll();
... now i have to update employee name how i do this by using linq....?
Posted

Try this:
Follow the steps:
1. Create the object of your DataContext.
2. Get the row of the table which you want to update.
3. Update the values in the required columns.
C#
//context is the object of your datacontext
var dbEmpInfo = context.Employee
    .Where(w => w.EmployeeID == 101)
    .SingleOrDefault();

if (dbEmpInfo != null)
{
    dbEmpInfo.FirstName = "Amit";
    db.SubmitChanges();
}

You should try searching Google[^] also.

--Amit
 
Share this answer
 
v2
now you should update -
SQL
foreach (var elementEmp in lstEmployee)
              {
//perform your update query here.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900