-2

I am using Generic Repository Pattern for my recent project. Suppose my table has 100000 records and if I load all records at a time, it is taking too much time. i.e below mentioned method will return all records.

 public async Task<IEnumerable<T>> GetAll()
    {
        return await dbSet.ToListAsync();
    }

My UI layer is still waiting for 100000 records to load into the memory to bind my DOM in Jquery Datatable. Is there any mechanism to load 500 records in each call automatically or I have to implement this in mechanism in my business layer?

1 Answers1

0

In general, it's worth noting that we do not use the repository to get the query from the database And we use other mechanisms for get query from database So, in my opinion, do not try to use the repository to get a query from database.if you're forced to use the repository to get a query, you're actually turning the repository into DOA(Data Access Object). Finally, if you are trying to use the tank to get a queue, you can not use a generic repository. You should use DbSet to get a customize query from database. In the book

Scott Millet (Patterns, Principles, and Practices of Domain-Driven Design)

Repository section - There is a complete article about Generic Repository

amirhamini
  • 526
  • 5
  • 14