LINQ to SQL Update

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

In LINQ to SQL, you can easily update data in a database by modifying any property of the object which is associated with Table<TEntity> collection and then call SubmitChanges() method. LINQ to SQL will translate your changes into the appropriate SQL UPDATE commands.

The following code updates the address of a customer whose first name is "Maria".

using (var db = new CustomerDataContext(@"Data Source=(localdb)\ProjectsV13;Initial Catalog=CustomerDB;"))
    var customer = db.Customers
        .Where(c => c.FirstName == "Maria")
    customer.Address = "Obere Street 59";

Got any LINQ to SQL Question?