Updating data in database in asp net

We can make any number of queries and changes we want using a LINQ to SQL Data Context, and these changes will all be tracked together.

Below are the first three parts of my LINQ to SQL series: In today's blog post I'll cover how we we can use the data model we created earlier, and use it to update, insert, and delete data.For example, I could write the below code to create a new Product and associate it with an existing "Beverages" category in my database like so: Note above how I'm adding the Product object into the Category's Products collection.This will indicate that there is a relationship between the two objects, and cause LINQ to SQL to automatically maintain the foreign-key/primary key relationship between the two when I call "Submit Changes()".Below is a class model created for the Northwind sample database and which I'll be using in this blog post: When we designed our data model using the LINQ to SQL data designer above we defined five data model classes: Product, Category, Customer, Order and Order Detail.The properties of each class map to the columns of a corresponding table in the database.

Search for updating data in database in asp net:

updating data in database in asp net-67

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating data in database in asp net”