Updating data using linq to sql White picture sharing chat
NET Framework 3.5 release, and which enables you to model relational databases using . You can use LINQ expressions to query the database with them, as well as update/insert/delete data.
We'll want to-do this with our newly created Insert Order SPROC: Our last step will be to tell our data access layer to use the Insert Order SPROC when inserting new Order objects into the database.
When building a LINQ to SQL data layer you'll usually want to encapsulate common LINQ queries (or SPROC invocations) into helper methods that you add to your Data Context class.
We can do this by adding a partial class to our project.
We'll first go to the Visual Studio "Server Explorer" window, expand into the "Stored Procedures" node of our database, and then right-click and choose "Add New Stored Procedure": We'll then create a new SPROC that we'll call "Insert Order" that inserts a new order record into our Orders table: Notice above how the SPROC defines the "Order ID" parameter as an output param.
This is because the Order ID column in the database is an identity column that is set to auto-increment each time a new record is added.