I have a fairly short, but it seems to me, questionable query in terms of performance:
List<Example> examples = await _dataContext.Examples.ToListAsync();
foreach (Example example in examples)
{
User? user = await _dataContext.Users.FindAsync(example.UserId);
if (user != null) user.Points += example.Worth * example.Multiplier;
}
await _dataContext.SaveChangesAsync();
await _dataContext.Database.ExecuteSqlRawAsync("TRUNCATE TABLE\"Examples\"");
Is this option really bad for performance and are there any alternatives to it? Thank you!