SQL Server RowVersion

Quick Question Re: RowVersion Implementation.

I want to include it in my next database (now it's designing), and I'm thinking of two different ways:

  • RowVersion row in all tables
  • A separate RowVersion table that has a table identifier as a foreign key and is associated with it.

Has anyone tried this? If so, what mistakes or about you have you experienced?

I am using LINQ to access data using C # 2008 and SQL Server 2008.

Thanks,

James

+6
c # sql sql-server linq
source share
3 answers

If you use LINQ to SQL, it is advisable to include a timestamp / rowversion column for each entity table, since this allows LINQ to use optimistic concurrency very easily and gives slightly better performance for updates (as LINQ should query only the timestamp column and not compare other columns for changes )

So, go to the first option. The second option is not a starter, really.

+11
source share

Add a rowversion row to the main table - adding it to the second table, and binding to it will result in poor performance.

As Sam said above, LINQ benefits from having rows in the table - but I don't think it will work with a linked table.

+2
source share

Suppose by RowVersion you mean a data type with a timestamp (bad name).

Use the rowversion column in all tables.

SQLServer automatically updates the column.

I have never used LINQ to SQL (for example, my SQL code), but the Rowversion column is very useful in concurrency updates.

Just use "WHERE ID = @ID AND ROWVERSION = @RV" to handle concurrent updates.

DO NOT use your second option!

+1
source share

All Articles