Hello,
I am trying to update my database table as follows in the service method:
Here is the generic repo update and GetGamesAsync:
If there are a couple of records in the query (gameBankResult ) there is no problem, the update is very fast. But if there are let's say 2000 records it takes 2 minutes. By the way, there is always 1 result in gameBankResult, let's say a business rule. What can be the problem?
Best Regards.
I am trying to update my database table as follows in the service method:
C#:
//Query GameBank database
var gameBankResult = await _unitOfWork.GameBankRepository.GetGamesAsync(g =>
g.productCode == requestDto.productCode && g.referenceId == Guid.Empty);
if (gameBankResult.Count() >= requestDto.quantity)
{
var k = requestDto.quantity - 1;
for (var i = k; i >= 0; --i)
{
gameBankResult[i].referenceId = gameRequest.referenceId;
gameBankResult[i].requestDateTime = DateTime.Now;
gameBankResult[i].responseDateTime = DateTime.Now;
}
//Update GameBank
_unitOfWork.GameBankRepository.Update(gameBankResult[k]);
Here is the generic repo update and GetGamesAsync:
C#:
public virtual void Update(TEntity entityToUpdate)
{
dbSet.Attach(entityToUpdate);
context.Entry(entityToUpdate).State = EntityState.Modified;
}
C#:
public virtual async Task<List<TEntity>> GetGamesAsync(
Expression<Func<TEntity, bool>> where)
{
return await dbSet.Where(where).ToListAsync();
}
If there are a couple of records in the query (gameBankResult ) there is no problem, the update is very fast. But if there are let's say 2000 records it takes 2 minutes. By the way, there is always 1 result in gameBankResult, let's say a business rule. What can be the problem?
Best Regards.
Last edited by a moderator: