Deleting with LINQ to SQL
You can delete an entity with LINQ to SQL by using code like the following:
This code starts by retrieving the record with an Id
of 1
from the Movie database table. Next, the Movie
entity is removed from the Movies
collection. Finally, this change is submitted to the database and the following SQL command executes:
Note
I’m assuming in this section that you have added a Version
property to your Movie database table. If not, see the previous section, because you should add a Version
property when deleting for the same ...
Get ASP.NET 4 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.