How to make a count of records that a query would return in Linq (Entity Framework) in C #? The equivalent in SQL is to make a SELECT COUNT(*)
.
Note that I want to receive the direct count of records, just like a SELECT COUNT (*) would do, and not receive the results and do a count afterwards. So a .Select().Count()
or .Where().Count()
does not solve my situation. Not even that:
var result = from tbl in tabela
select tabela;
int contagem = result.Count();
How would you do other operations in a single query, for example: Min, Max, or arithmetic operations between two queries (ex: SELECT(...)/SELECT COUNT(*)
)?