Update through Linq-to-SQL DataContext not working.

Posted by Puneet Dudeja on Stack Overflow See other posts from Stack Overflow or by Puneet Dudeja
Published on 2011-03-06T15:31:19Z Indexed on 2011/03/06 16:10 UTC
Read the original article Hit count: 190

Filed under:
|

I have created a small test for updating table using Linq-to-SQL DataContext as follows:

using (pessimistic_exampleDataContext db = new pessimistic_exampleDataContext())
{
   var query = db.test1s.First(t => t.a == 3);

   if (query.b == "a")
      query.b = "b";
   else
      query.b = "a";

   db.SubmitChanges();
}

But after executing this code in a console application in Main method, when I select records from the table, the record is not updated.

I have debugged through the code, and it is not even throwing any exception.

What can be the problem ?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about linq-to-sql