Is there a way to get the row count of a complex Linq query and millions of records without hitting the db twice or writing 2 separate queries??
If you need a quick solution you can use XPagedList https://github.com/dncuug/X.PagedList. XPagedList is a library that enables you to easily take an IEnumerable/IQueryable, chop it up into "pages", and grab a specific "page" by an index. For example
var products = await _context.Products.ToPagedListAsync(pageNumber, pageSize)