TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
LINQ To SQL:Delete an entity
Vijai Anand Ramalingam
Jun 22, 2011
4.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog we will be seeing how to delete an entity.
EmpDetails Table:
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();
}
}
}
Next Recommended Reading
Resolve LINQ to Entities Does Not Recognize the Method ToString Exception