none
optimistic Concurrency RRS feed

  • Question

  • Hello,

      I have a couple of questions. I am using .net framework 4.0.

    1. I would like to turn off optimistic concurrency because of the overhead it may impose. what is the best way to do this? I hate going through every column in my dbml tables and setting it to never.

    2. I am calling stored procedures for deletes ,updates and inserts using linq. What is the way to know if a procedure was successful? The IExecuteResult is returned as 0 all the time even when the update succeeds. I wonder how can I get the number of rows affected.

     

    Monday, December 6, 2010 9:07 AM

All replies

  • Can anyone please answer my questions? I have had those questions posted since December 6 !!!!!!!

    Thank you

    Monday, December 20, 2010 11:45 AM
  • I think you maybe wording your question wrong, or misunderstand the concept.  I use the 3.5 framework, but I didn't see that there were any changes on this from 3.5 to 4.0.  Optimistic concurrency is only used when the data table has a column of type timestamp.  Additionally it is the only use of that column type.  Sql automatically generates the timestamp on insert or update.  In order to update or delete, the object must have the same timestamp as the current timestamp in the database.  The overhead is extremely small.  I believe it is only a 64bit field.  So you have an additional 64 bits per row in memory and transported from SQL to your application.

    In summary, don’t add a timestamp column if you don’t want optimistic concurrency, but this shouldn’t be an performance concern.

    Tuesday, December 21, 2010 10:38 PM
  • I am not sure what you mean exactly when you mentioned the timestamp column. Here is an example where the 'changeConflictException' is thrown and there is no timestamp column in the data table.

    http://www.codeproject.com/KB/linq/LINQConcurrency.aspx

     

    Another thing:

    I am calling stored procedures for deletes ,updates and inserts using linq. What is the way to know if a procedure was successful? The IExecuteResult is returned as 0 all the time even when the update succeeds. I wonder how can I get the number of rows affected when not using submitchanges() method and executing stored procs directly.

    Wednesday, December 22, 2010 11:00 PM
  • http://msdn.microsoft.com/en-us/library/ms378487(v=SQL.90).aspx

    This will tell you the ammount of rows afected.

    Regards

    Wednesday, December 29, 2010 3:00 PM
  • hi

     

    I think this article is a good one to improve your desired performance:

     

    http://www.sidarok.com/web/blog/content/2008/05/02/10-tips-to-improve-your-linq-to-sql-application-performance.html


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Regards, Alireza
    Thursday, December 30, 2010 12:21 PM