This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20255|Reply: 0

[Source] ConcurrencyCheck feature of data annotation feature [Code-First series]

[Copy link]
Posted on 1/22/2017 10:44:12 AM | | | |
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.





Previous:Ali Da Yu (Ali Big Fish) Easy language SMS sending source code
Next:chrome launch parameters
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com