The venom in this query is in the first words: IEnumerable<application>
. If you replace that by var
(i.e. IQueryable
) the query will be translated into SQL up to and including the last Count()
. This will take considerably less time, because the amount of transported data is reduced to almost nothing.
Further, as bobek already mentioned, you don't need the Include
s as you're only counting context.applications
items.
Apart from that, you will always notice overhead of using an ORM like Entity Framework.