1

i am using .net 4.0 , i hava a table agent , the agent has a field "accessed_date" which gets updated every 2 seconds , when he is logged in.

i have a service operation "UpdateAgent" , and as the name suggest it updates the agent , i dont want this operation to throw ChangeConflictException , if only the field "accessed_date" is updated , since i know , thats its normal that it will get updated , how i disable ChangeConflictException to get fired on submitchanges .

thanks Jamal.

1 Answers1

2

You are implicitly using "Optimistic Concurrency". By default the UpdateCheck attribute is set to Always. Set the UpdateCheck to None for the accessed_date column.

Here's how (haven't tried, hope this works - if not, google for UpdateCheck.Never and check if one of the offered solutions works for you): Setting the UpdateCheck.Never mode by default in Visual Studio 2010 DBML designer (MS SQL/ASP.NET MVC)

Community
  • 1
  • 1
Olaf
  • 10,049
  • 8
  • 38
  • 54
  • what if i want to disable Optimistic Concurrency for the whole table. – Muhammad Jamal Shaikh Jan 09 '11 at 20:36
  • AFAIK, there is no direct way. If you really need to, you can either use an ordinary ExecuteCommand (meaning you write SQL strings again) or use Attach() - see articles http://blogs.msdn.com/b/dinesh.kulkarni/archive/2008/06/01/linq-to-sql-tips-7-minimal-update-when-you-don-t-want-optimistic-concurrency-check.aspx and http://www.richardbushnell.net/2008/02/18/how-to-update-data-with-linq-to-sql/ for further details. – Olaf Jan 11 '11 at 06:46
  • the method you defined will not work for me , beccause i have a timestamp column on this table . so updateecheck is set to false for each column except the time stamp column.IS THERE ANY OTHER SOLUTION NOW ? – Muhammad Jamal Shaikh Jan 30 '11 at 23:33
  • How about removing the timestamp column from the dbml? And adding this attribute doesn't help either? [Column(Storage=“Timestamp”, UpdateCheck=UpdateCheck.Never)] public string Timestamp .... – Olaf Feb 17 '11 at 09:13