Home > OS >  Does CountAsync method in EF Core results to SaveChanges or not?
Does CountAsync method in EF Core results to SaveChanges or not?

Time:10-25

I have an important question which I couldn't find the answer anywhere! Suppose we call the Count or CountAsync method in EF or EFCore like this:

public async Task<int> Count()
{
    return await _context.Set<TEntity>().CountAsync();
}

Does it results to save or add the entities into the database or not?

Thank you.

CodePudding user response:

Does it results to save or add the entities into the database or not?

No. Queries never write to the database. Only SaveChanges writes to the database.

  • Related