I found this code from a tutorial:
Product bev1 = beverages.ElementAtOrDefault(10);
if (bev1 != null)
{
Console.WriteLine("The price of {0} is {1}. Update to 20.0",
bev1.ProductName, bev1.UnitPrice);
bev1.UnitPrice = (decimal)20.0;
}
// submit the change to database
db.SubmitChanges();
How do we know if the update was successful?
If the update is not successful an exception will be thrown. If no exception is thrown, it was successful.