Hi,
ABP Version 2.8.0
I have an entity of type MyEntity: AggregateRoot<long>
I can create default repositories and get lists of items successfully using IRepository<MyEntity, long>
But I have behaviour that does not make sense to me
If I use var newlyCreatedItem = _myRepository.InsertAsync(newItem)
Id = 0If I use var newlyCreatedItem = _myRepository.InsertAsync(newItem, autosave: true)
IdWhy is this so? Any idea what I could've done wrong?
Thanks in advance for you help!
See https://docs.abp.io/en/abp/latest/Unit-Of-Work#alternative-to-the-savechanges
Hi @liangshiw
Thank-you for responding, but why do you close all my questions without confirmation of resolution? Before one even reviews your answer.
I do not know if it is ABP project policy, but it seems only you do it when you respond to a question.
I have asked questions on a number of repositories and I this has to be the only situation where every question is closed before resolution. I do not believe it fosters a good spirit to close all questions when you close questions just for the sake of keeping their numbers down.
I will have a look, but thank-you.
Unfortunately, the linked documentation does not give any possible reason why it is behaving that way.
I would really appreciate if you considered my feedback concerning the way you respond and immediately close a question without considering feedback on your answer.
Sorry for bothering you, but you should check the official documentation before asking questions, because most of the answers are in the documentation.
Let me answer your question:
For EF Core, the repository operation will not be saved to the database immediately, after the method returns, it will be saved by the unit of work.
If your intent is just to save the changes after creating/updating/deleting an entity, it is suggested to use the autoSave option.
Note-1: All changes are automatically saved when a unit of work ends without any error. So, don't call SaveChangesAsync() unless you really need it.