Handling Optimistic Concurrency
Of course, the ADO.NET Entity Framework provides the ability to handle optimistic concurrency exceptions. You need to intercept eventual System.Data.Entity.Infrastructure.DbUpdateConcurrencyException
instances. When intercepted, you need to determine what entries were not updated in the database by using the Entries
property of the exception instance and make an appropriate decision. The following code revisits the UpdateProduct
custom method described in the “Updating Entities” subsection, providing the first example:
Sub UpdateProduct() Try Dim check = northwindContext.Products. Single(Function(p) p. ProductName = "Italian spaghetti") ...
Get Visual Basic 2015 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.