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.
Each instance of a class entity represents a row within the database table.Note the use of a generic index based scheme for reading data from the edit row and writing the new data to the appropriate row in the Data Set.Since the data in the Data Grid may not be synchronized with the data in the Data Set, you must find the proper row in the Data Set using the primary key of the selected row.For example, I could write the below code to update the price and # of units in stock of the "Chai" product in the database: When I call northwind.Submit Changes() above, LINQ to SQL will dynamically construct and execute a SQL "UPDATE" statement that will update the two product property values we modified above.Finally, the Sql Adapter supports Optimistic Concurrency by generating SQL UPDATE statements that look for unaltered records using the @original values stored in the Data Set. If you look at the file Web Form1in the HTML view you will see where the On Update Command, On Edit Command and On Cancel Command property is set to the appropriate event handler.However, if you want to implement Optimistic Concurrency, you will need to persist the Data Set in the View State or Session. The Data Grid will use these properties to register the button event handlers: " Height="270px" Width="679px" On Update Command="Data Grid1_Update" On Cancel Command="Data Grid1_Cancel" On Edit Command="Data Grid1_Edit" On Delete Command="Data Grid1_Delete" Border Color="Blue" On Item Command="Item_Click" Allow Sorting="True" On Sort Command="Data Grid1_Sort" Allow Paging="True" On Page Index Changed="Data Grid1_Page" Back Color="#C0FFFF" Using the Design view, you can add a "Edit", "Update" and "Cancel" button to the Data Grid by right clicking on the Data Grid and choosing the property builder.LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .NET Framework 3.5 release, and which enables you to easily model relational databases using . You can use LINQ expressions to query the database with them, as well as update/insert/delete data.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.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.