How much overhead does 'Update Check' have for LINQ UPDATES

后端 未结 5 1143
温柔的废话
温柔的废话 2020-12-14 11:09

I have a simple row that I edit using LINQ. It has about 30 columns, including a primary key numeric sequence.

When an UPDATE is performed through LINQ, the UPDATE s

5条回答
  •  爱一瞬间的悲伤
    2020-12-14 12:03

    Personally, I like the simplicity of a single timestamp/row-version column; set this as the only column to be checked (IIRC, happens automatically for timestamp), and you're sorted - you should then get TSQL like:

    exec sp_executesql N'UPDATE [dbo].[SiteVisit]
    SET [TotalTimeOnSite] = @p2, [ContentActivatedTime] = @p3
    WHERE ([SiteVisitId] = @p0) AND ([Timestamp] = @p1)
    

    This relies on their not being concurrent (non-conflicting) updates to the same record; with a timestamp/row-version etc, any conflicting update will cause the second to abort, even if they updated different columns etc.

提交回复
热议问题