LINQ To SQL:Update an entity

EmpDetails Table:

LinqTable.png


Code:


To update an entity.


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
LINQ
{
class Program
{
static void Main(string[] args)
{
DataClassesDataContext dc = new DataClassesDataContext();
var empQuery = (from emp in dc.EmpDetails
where emp.Dept == "MOSS"
select emp).First();
empQuery.Name =
"Vijay";
dc.SubmitChanges();
}
}
}