You need to change IEnumerable<T> records to IQueryable<T> records. IEnumerable causes you to load all your database data to memory while IQueryable is SQL. You can verify this by printing the generated SQL log.
IEnumerable<T> records
IQueryable<T> records
IEnumerable
IQueryable