mrblah
mrblah

Reputation: 103677

How are updates handled with Linq to SQL?

Do you have to write update statements with Linq to SQL?

Upvotes: 0

Views: 69

Answers (1)

JoshJordan
JoshJordan

Reputation: 12975

Kinda. You can use it somewhat like an ORM in that you can update your in-memory data model, and then execute a dynamically generated UPDATE statement when you submit changes. For example:

using (MyDataContext db = new MyDataConext())
{
     db.Clients.First().Salary = 50000;
}

does not perform an update, but

using (MyDataContext db = new MyDataConext())
{
     db.Clients.First().Salary = 50000;
     db.SubmitChanges();
}

does.

Upvotes: 2

Related Questions