The previous chapter primarily covered how you can read data with LINQ to SQL. The next step is understanding how to modify the data in a database using LINQ to SQL.
Luckily, by using entities, updating a column for a specific row in a table is as simple as changing a property of an entity instance. For example, the following code reads a product, increases its price by 5 percent by modifying the UnitPrice property, and then applies the in-memory changes to the database by calling SubmitChanges:
Product product = db.Products.Single(p => p.ProductID == 42); product.UnitPrice *= 1.05M; db.SubmitChanges();
In this chapter, you will see how to handle entity updates applied to the database, and investigate concurrency, ...