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)
-
0
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
-
0
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>