Deleting Entities

Deleting an entity works similarly to update, at least for retrieving the entity instance. Deletion is performed by invoking the DeleteOnSubmit method, which works opposite to the InsertOnSubmit. The following is an example, which also checks if the entity exists:

image

Remember how the custom SaveChanges method invokes the NorthwindDataContext.SubmitChanges one. The following code shows invoking the previous method for performing a product deletion:

image

Similarly to InsertAllOnSubmit, you can also invoke DeleteAllOnSubmit to remove multiple ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.