Let’s say you want to execute a code block when Book
table is not empty. In Entity Framework Core, we can achieve this in two ways (there might be others but I am unaware of them):
Option 1:
if(context.Books.Count()>0)
{
// do something
}
Option 2:
if (context.Books.Any())
{
// do something
}
Note 📢: I am testing these queries against a table containing 1 million rows.
[Read More]