Is there a method that returns the next 10 entries. For example, you need to make pagination. There is a record ID after which I need to return the following 10 records. What not to write in manual this crutch can eat something adequate where you transfer id and at an output you receive a trace of 10 records after it. thank

  • There are Skip and Take, they are exactly normally broadcast in sql - Andrey NOP
  • well, usually during pagination, I use the page number and the number of records on the page and are used to calculate them and not by entity indices - Sasuke

1 answer 1

var indexSkip = allElements.FindIndex(e => e.Id == id) + 1; return allElements.Skip(indexSkip).Take(20); 
  • allElements I understand already ready List of all records? - FX_Sektor 2:46
  • @FX_Sektor - By no means List ! This should be a table ( DbSet / IQueryable ) EntifyFramework. You do not want to pull all the data at once from the database to the client. - Alexander Petrov
  • And, by the way, sorting is necessary. Otherwise, the results are unpredictable. - Alexander Petrov