How can I use Dapper and X.PagedList (for pagination) which needs IQueryable together?

43 Views Asked by At

I want to use Dapper with the most popular pagination package on Nuget - X.PagedList.

Here is an example usage of X.PagedList from their website: enter image description here

It needs IQueryable but Dapper returns IEnumerable:

var posts = await _dbConnection.QueryAsync<PostDTO>(
    "SELECT * FROM Posts WHERE Title LIKE @SearchTerm",
    new
    {
        SearchTerm = "%" + request.SearchTerm + "%"
    });

How can I solve that problem?

  • AsQueryable() isn't a solution
  • not using Dapper isn't a solution because it protects against SQL injection
0

There are 0 best solutions below