Updating Entities
Updating existing entities is even easier than adding new ones. First, you need to obtain the instance of the entity you want to update. When you get the instance, you edit its properties and then invoke the DataContext.SubmitChanges
method. The following code provides an example:
Sub UpdateProduct(ByVal productInstance As Product) 'Throws an exception if a null value is passed If productInstance Is Nothing Then Throw New NullReferenceException Else With productInstance .ProductName = "Italian Linguine" .UnitsInStock = 100 End With End If SaveChanges()End Sub
This method requires an instance of the Product
entity to be updated. To get an ...
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.