LINQ To SQL:Delete an entity

EmpDetails Table:

LinqTable.png


Code:


To delete an entity from EmpDetails table.


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.ID == 1
select emp).First();
dc.EmpDetails.DeleteOnSubmit(empQuery);
dc.SubmitChanges();
}
}
}