|
The ConcurrencyCheck feature can be applied to the properties of a domain class. When EF performs an update operation, Code-First puts the value of the column in the where condition statement, and you can use this CurrencyCheck feature to use the existing columns for concurrency checking, rather than using a separate TimeStamp column for concurrency checking. Look at the code below: Next, let's modify the test code for the main function:
Then the error concurrency message is:
exec sp_executesql N'UPDATE [dbo]. [StudentInfo] SET [StudentName] = @0, [StdId] = @1 WHERE ((([StudentKey1] = @2) AND ([StudentKey2] = @3)) AND ([StudentName] = @4)) ',N'@0 nvarchar(20),@1 int,@2 int,@3 int,@4 nvarchar(20)',@0=N'Test Only For one',@1=1,@2=1,@3=1,@4=N'Test Only For one' Please note:
Note that TimeStamp attribute can only be applied to a single byte array property in a class, whereas ConcurrencyCheck attribute can be applied to any number of properties with any datatype.
The TimeStamp feature can only be used in classes with a single-byte property, but the ConcurrencyCheck feature can be used in any number and type of property.
|