How to do update sql in LinQ

  • Thread starter Thread starter Paul
  • Start date Start date
Hi,
Haw can i do this in linQ:
UPDATE Table SET Field1="Value" WHERE idTable==5

Linq to SQL or EF ?

It's best to forget about Sql. It allows to expose your data as *objects* so
you just update the object instance and you call the SaveChanges method (or
SubmitChanges if Linq To SQL).

See :

http://msdn.microsoft.com/en-us/library/bb386870.aspx and around for details
if Linq To EF...

If you have a particular problem in using the doc, you may want to be more
explicit about the issue you ran into...
 
Paul said:
Hi,

Haw can i do this in linQ:
UPDATE Table SET Field1="Value" WHERE idTable==5

Thanks

You have to query for the object out from whatever table it is by
idtable == 5.

You make changes obj.Field1 = '2';

Context.Savechanges();
 
Back
Top