How to delete records using LINQ programmatically?

Posted by SheoNarayan under LINQ category on | Views : 14035
Write code link following.

// LINQ Object
DataUsersClassesDataContext dataUsers = new DataUsersClassesDataContext();
// Database object, find the record to delete
ThisUser user = dataUsers.Users.Single(u => u.UserID == XXXXX);
dataUsers.Users.DeleteOnSubmit(user); // not physically deleted, it is marked as deleted but still pending to delete
dataUsers.SubmitChanges(); // physically delete from database

Comments or Responses

Login to post response