- ABP Framework version: v7.2.2
- UI Type: N/A
- Database System: EF Core SQL Server
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace: N/A
When an entity in the database is updated through an API call to the repository UpdateAsync method, I would expect it to return the concurrencyStamp that's updated in the database in the response. However it's returning the concurrencyStamp that was sent in the request. It returns the updated lastModificationTime and lastModifierId so I'm not sure why it doesn't return the updated concurrencyStamp
I've only found similar problems to this in Discord and the Abp support questions but no resolution.
Steps to reproduce the issue:
- Create a new module or application using Abp Suite
- Create an entity as FullAuditedAggregateRoot. For example Note
- Add properties to the entity
- Save the project and generate the code
- The Dto for the entity should have
public string ConcurrencyStamp { get; set; }
- In the domain service manager (e.g. public class NotesManager : DomainService) the UpdateAsync method should have
note.SetConcurrencyStampIfNotNull(concurrencyStamp);
return await _noteRepository.UpdateAsync(note);
- Using postman or some other method, call the POST method to add a new entity
- Using postman or some other method, call the PUT method to update the entity created in the previous step
- Make note of the concurrencyStamp returned
- Look in the database table for the entity and note the concurrencyStamp in the table
- Compare the concurrencyStamp of the PUT request payload and response
- The concurrency stamps from in the request and response are the same
Here's the PUT request payload: { clientId: "6df04165-acd7-18dd-7ccd-3a0d2bc61b4a" clientName: "Peyton Floris" concurrencyStamp : "dbca526c0d9f4b69b49a4cf992fc0079" text: "Something something" }
Here's the response payload { "clientId": "6df04165-acd7-18dd-7ccd-3a0d2bc61b4a", "clientName": "Peyton Floris", "text": "Something something", "concurrencyStamp": "dbca526c0d9f4b69b49a4cf992fc0079", "isDeleted": false, "deleterId": null, "deletionTime": null, "lastModificationTime": "2024-01-25T11:17:09.740494-06:00", "lastModifierId": "9bb21ac9-d3ac-887e-b521-3a0c9c5d08d6", "creationTime": "2023-11-27T09:40:40.03589", "creatorId": "9bb21ac9-d3ac-887e-b521-3a0c9c5d08d6", "id": "b5a37273-6cfc-3a7f-f4f3-3a0f239d6c90" } Here's the concurrency stamp showing in the database. Please note, I'm the only one hitting this database in test 75aeaf08163242128737360e611e1496
10 Answer(s)
-
0
hi
Please share your test app. liming.ma@volosoft.com
Thanks.
-
0
Hi,
I just gave you read access to the GitHub repository: https://github.com/cpr-ops/notes-service
-
0
hi
I can't build your solution.
error MSB4019: The imported project "common.props" was not found. Confirm that the expression in the Import declaration "../../../../common.props" is correct, and that the file exists on disk.
-
0
Since this is a microservice that's part of our Microservice solution, I created a minimal repository using the Microservice Template and copied the notes service.
You should have everything you need to run it.
https://github.com/roger-cprops/CprOnAbp-Test
-
0
hi
Set
autoSave: true
you will get the latestConcurrencyStamp
note.SetConcurrencyStampIfNotNull(concurrencyStamp); return await _noteRepository.UpdateAsync(note, autoSave: true);
-
0
That fixed it. Thank you.
Is there mention of this in the documentation? If so, can you send a link?
-
0
hi
https://docs.abp.io/en/abp/latest/Concurrency-Check
However, your problem is related to the transaction. autoSave: true will commit the transaction and get the latest
ConcurrencyStamp
-
0
Hi @mailiming,
I did review that document earl and as you pointed out, the autosave parameter is not mentioned.
It might be helpful to other to to update the documentation.
Thanks
-
0
Thanks. I will update the document.
-
0
https://github.com/abpframework/abp/pull/18908