How to make UPDATE queries in LINQ to SQL?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-03-27T16:51:13Z Indexed on 2010/03/27 16:53 UTC
Read the original article Hit count: 119

Filed under:
|

I like using LINQ to SQL. The only problem is that I don't like the default way of updating tables.

Let's say I have the following table with the following columns:

ID (primary key), value1, value2, value3, value4, value5

When I need to update something I call

UPDATE ... WHERE ID=@id

LINQ to SQL call

UPDATE ... WHERE ID=@id and value1=@value1 and value2=@value2 and value3=@value3 and value4=@value4 and value5=@value5

I can override this behavior by adding

UpdateCheck=UpdateCheck.Never

to every column, but with every update of the DataContext class with the GUI, this will be erased. Is there any way to tell LINQ to use this way of updating data?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about linq-to-sql