Update query in Linq to Sql C# MVC

1712
Views
1
Answers

How to write update query in c# using Linq to SQL??

edit | flag
William Patrick
Asked on: Jun 16, 2011 at 5:14AM

1 Answers

3
1
3

I have taken North wind database for example.
If you want to update the Product name in the table Products where Product Id equals 1,try this Query..

NorthwindEntities dbContext = new NorthwindEntities();
var product = (from p in dataContext.Products
               
where p.ProductID == 1
               
select p).Single();

product
.Name = "Updated product name";

dataContext
.SubmitChanges();
edit | flag
Gokul A
Answered on: Jun 16, 2011 at 7:09PM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags