How to delete records using LINQ programmatically?

SheoNarayan
Posted by SheoNarayan under LINQ category on | Views : 12663
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