Deleting Entities
Deleting entities is also a simple task. You first need to get the instance of the entity you want to remove and then invoke the ObjectSet(Of T).DeleteObject
method. The following code shows how to get the instance of the specified product and then to remove it first from the model and then from the database:
Same as in previous code, we take advantage of the Single
method that throws an InvalidOperationException
if the object does not exist.
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.