Ends in:
2 DAYS
14 HRS
27 MIN
25 SEC
Ends in:
2 D
14 H
27 M
25 S
Open Closed

The CompleteAsync method does not work when isRequired is set to false #5079


User avatar
0
ademaygun created
  • ABP Framework version: v5.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I am debugging the code below. When I check the database after executing the CompleteAsync() command, I observe that there is no change. The change only occurs when the method is completed. Don't you think this is misleading?

public async Task UpdateAsync(string name)
        {
            List<string> myList = new() { "1", "2" };
            foreach (var id in myList)
            {
                using (var uow = unitOfWorkManager.Begin(isTransactional: true))
                {
                    var product = await productRepository.GetAsync(id);
                    product.SetName(name);
                    await productRepository.UpdateAsync(product);
                    await uow.CompleteAsync();
                }
            }
        }

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi This is because the UpdateAsync is already in a unit of work.

  • User Avatar
    0
    ademaygun created

    Hi, Even though await uow.CompleteAsync(); is being called, it is not performing any operation. In this case, I would expect it to write(commit) to the database or throw an error.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    CompleteAsync will do nothing if there is a parent unit of work.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35