From 4f3ea9d874e14ba573a7c9464da28f2c7839118c Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 1 Feb 2024 09:45:25 +0800 Subject: [PATCH 1/3] Update Concurrency-Check.md --- docs/en/Concurrency-Check.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/Concurrency-Check.md b/docs/en/Concurrency-Check.md index bf31d3db102..56c5c21895a 100644 --- a/docs/en/Concurrency-Check.md +++ b/docs/en/Concurrency-Check.md @@ -29,6 +29,8 @@ public interface IHasConcurrencyStamp * While a new record is **creating**, if the entity implements the `IHasConcurrencyStamp` interface, ABP Framework automatically sets a unique value to the **ConcurrencyStamp** property. * While a record is **updating**, ABP Framework compares the **ConcurrencyStamp** property of the entity with the provided **ConcurrencyStamp** value by the user and if the values match, it automatically updates the **ConcurrencyStamp** property with the new unique value. If there is a mismatch, `AbpDbConcurrencyException` is thrown. +> If there is a unit of work, You need to call the [SaveChangesAsync](./Unit-Of-Work.md#savechangesasync) method to get the generated `ConcurrencyStamp` when creating or updating. + **Example: Applying Concurrency Control for the Book Entity** Implement the `IHasConcurrencyStamp` interface for your entity: From 1843db905b4a890ca1c218202ceab5ba0df5488d Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Thu, 1 Feb 2024 09:34:21 +0300 Subject: [PATCH 2/3] Update Concurrency-Check.md --- docs/en/Concurrency-Check.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/Concurrency-Check.md b/docs/en/Concurrency-Check.md index 56c5c21895a..a0a97d8d988 100644 --- a/docs/en/Concurrency-Check.md +++ b/docs/en/Concurrency-Check.md @@ -29,7 +29,7 @@ public interface IHasConcurrencyStamp * While a new record is **creating**, if the entity implements the `IHasConcurrencyStamp` interface, ABP Framework automatically sets a unique value to the **ConcurrencyStamp** property. * While a record is **updating**, ABP Framework compares the **ConcurrencyStamp** property of the entity with the provided **ConcurrencyStamp** value by the user and if the values match, it automatically updates the **ConcurrencyStamp** property with the new unique value. If there is a mismatch, `AbpDbConcurrencyException` is thrown. -> If there is a unit of work, You need to call the [SaveChangesAsync](./Unit-Of-Work.md#savechangesasync) method to get the generated `ConcurrencyStamp` when creating or updating. +> If there is a unit of work, you need to call the [SaveChangesAsync](./Unit-Of-Work.md#savechangesasync) method to get the generated `ConcurrencyStamp` when creating or updating. **Example: Applying Concurrency Control for the Book Entity** From d978a036ec0add068154712486b5e61d24fe291e Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 1 Feb 2024 14:49:20 +0800 Subject: [PATCH 3/3] Update `Concurrency-Check.md`. --- docs/en/Concurrency-Check.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en/Concurrency-Check.md b/docs/en/Concurrency-Check.md index a0a97d8d988..25e60713c7a 100644 --- a/docs/en/Concurrency-Check.md +++ b/docs/en/Concurrency-Check.md @@ -76,8 +76,8 @@ public class BookAppService : ApplicationService, IBookAppService book.ConcurrencyStamp = input.ConcurrencyStamp; //set other input values to the entity ... - - await BookRepository.UpdateAsync(book); + //use autoSave: true to get the latest ConcurrencyStamp + await BookRepository.UpdateAsync(book, autoSave: true); } } ``` @@ -136,8 +136,8 @@ public class BookAppService : ApplicationService, IBookAppService book.ConcurrencyStamp = input.ConcurrencyStamp; //set other input values to the entity ... - - await BookRepository.UpdateAsync(book); + //use autoSave: true to get the latest ConcurrencyStamp + await BookRepository.UpdateAsync(book, autoSave: true); } } ```