5
foreach (var tour in Tours)
            {
                await DbInstance.InsertOrReplaceAsync(tour.Guide);
                await DbInstance.InsertOrReplaceAsync(tour.Client);
            }

This block takes 6 seconds to execute !?

I have only 10 tours in Tours list and database schema is really simple. What is the problem here?

EDIT (SOLUTION):

In order to speed it up, wrap the multiple transactions like this:

await DbInstance.RunInTransactionAsync(connection =>
        {

           **YOUR FOR LOOP**
           //example
           connection.InsertAsync(tour.Guide);
        });
Millkovac
  • 101
  • 6

0 Answers0