concept this SQL command in category entity framework

appears as: this SQL commd, This SQL commd
Entity Framework Core in Action

This is an excerpt from Manning's book Entity Framework Core in Action.

Listing 8.13 SQL code to update Book where PublishedOn is a concurrency token
SET NOCOUNT ON;
UPDATE [Books] SET [Title] = @p0
WHERE [ConcurrencyBookId] = @p1 
      AND [PublishedOn] = @p2;    #1  
SELECT @@ROWCOUNT;    #2  

#1   The test fails if the PublishedOn column has changed, which stops the update.
#2   Returns the number of rows updated by this SQL command.

When EF Core runs this SQL command, the WHERE clause will find a valid row to update only if the PublishedOn column hasn’t changed from the value EF Core read in from the database. EF Core then checks the number of rows that have been updated by the SQL command. If the number of rows updated is zero, EF Core raises DbUpdateConcurrencyException to say that a concurrency conflict exists; EF Core can catch a concurrency conflict caused by another task either changing the PublishedOn column or deleting the row, when this task does an update.

Listing 8.13 SQL code to update Book where PublishedOn is a concurrency token
SET NOCOUNT ON;
UPDATE [Books] SET [Title] = @p0
WHERE [ConcurrencyBookId] = @p1 
      AND [PublishedOn] = @p2;    #1  
SELECT @@ROWCOUNT;    #2  

#1   The test fails if the PublishedOn column has changed, which stops the update.
#2   Returns the number of rows updated by this SQL command.

It’s possible to create an SQL command that would produce the same output as listing 12.10, but would calculate the ReviewCount only once. This SQL command would be quicker than EF Core’s version at the time of writing (version 2.0).