arch / UnitOfWork

A plugin for Microsoft.EntityFrameworkCore to support repository, unit of work patterns, multiple database with distributed transaction supported, and MySQL multiple databases/tables sharding supported.
MIT License
1.32k stars 343 forks source link

GetPagedList orderBy parameter #144

Open BrianARice opened 3 years ago

BrianARice commented 3 years ago

My database table Plan has a column called SortBy that I want to use to order the request... the below code is giving me the error: 'IQueryable' does not contain a definition for 'SortBy' and no accessible extension method 'SortBy' accepting a first argument of type 'IQueryable' could be found (are you missing a using directive or an assembly reference?)

        var repoPlan = _unitOfWork.GetRepository<Plan>();
        var list = repoPlan.GetPagedList(predicate: p => p.IsActive == true, orderBy: p => p.SortBy, pageIndex: skip, pageSize: take);

Any help on how to do this properly?

issue-label-bot[bot] commented 3 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

VergilGao commented 3 years ago
using System.Linq;

...

repo.GetPagedList(orderBy: x => x.OrderBy(p => p.SortBy));
...