Submit Changes() above, LINQ to SQL will calculate and execute an appropriate set of UPDATE statements to modify the products who had their Reorder Level property changed.Note that if a Product's property values weren't changed by the property assignments above, then the object would not be considered changed and LINQ to SQL would therefore not execute an update for that product back to the database.As I covered in Part 3 of this blog series, we can easily use LINQ syntax expressions to query and retrieve data from our database using this Northwind Data Context class.LINQ to SQL will then automatically translate these LINQ query expressions to the appropriate SQL code to execute at runtime.In the example data model we defined above this class was named "Northwind Data Context".The Northwind Data Context class has properties that represent each Table we modeled within the database (specifically: Products, Categories, Customers, Orders, Order Details).Each instance of a class entity represents a row within the database table.When we defined our data model, the LINQ to SQL designer also created a custom Data Context class that provides the main conduit by which we'll query our database and apply updates/changes.
I could then write the below code to loop over unpopular, expensive products and set the "Reorder Level" property of them to zero: When I call northwind.
Over the last few weeks I've been writing a series of blog posts that cover LINQ to SQL.
LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .
For example - if the "Chai" product's unitprice was already and the number of units in stock was 4, then calling Submit Changes() would not cause any database update statements to execute.
Likewise, only those products in the second example whose Reorder Level was not already 0 would be updated when the Submit Changes() method was called.