Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

UnitOfwork is Not Committing in Database #4822


User avatar
0
pankajmathur created

Hi, I am trying to delete 4 records, followed by insert 4 records. Both operations are happening inside UnitOfWork. See Code below. using (var unitOfWork = UnitOfWorkManager.Begin()) {

                            //Delete existing settings
                            _AddOnSettingRepository.DeleteAsync(p => p.PropertyName == "OAuthToken");
                            _AddOnSettingRepository.DeleteAsync(p => p.PropertyName == "OAuthTokenSecret");
                            _AddOnSettingRepository.DeleteAsync(p => p.PropertyName == "OAuthExpiresIn");
                            _AddOnSettingRepository.DeleteAsync(p => p.PropertyName == "OAuthExpiresAt");

                             //Insert new settings
                            AddXeroIntegrationSetting("OAuthToken", oauth_token);
                            AddXeroIntegrationSetting("OAuthTokenSecret", oauth_token_secret);
                            AddXeroIntegrationSetting("OAuthExpiresIn", oauth_expires_in);
                            AddXeroIntegrationSetting("OAuthExpiresAt", oauth_expires_at.ToString());


                            unitOfWork.Complete();
                        }

But, its not committing into the database. Could you please advise, what is wrong here?

Regards, Mahendra


2 Answer(s)
  • User Avatar
    0
    pankajmathur created

    Hello,

    We find out the reason, why it was not saving. Actually, before this unit of work, one more unit of work was used and due to some reason the outer unit of work was not getting complete, hence inner one also fails.

    Regards, Mahendra

  • User Avatar
    0
    alper created
    Support Team

    you can use TransactionScopeOption.RequiresNew to isolate your code block. <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#unit-of-work-scope">https://aspnetboilerplate.com/Pages/Doc ... work-scope</a>