How to pass orderby parameter value to a lambda function?

47 Views Asked by At

I am using this pattern https://gist.github.com/pmbanugo/8456744#file-ientityrepository-cs and function is

IEnumerable<T> GetAll(
            Expression<Func<T, bool>> filter = null,
            Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
            string includeProperties = null
            );

I want to pass parametere orderBy

_unitOfWork.GetAll(/*please pass orderby paramter here*/);

1

There are 1 best solutions below

1
nikstra On

Use named arguments to only pass the orderBy argument with a sorting function.

_unitOfWork.GetAll(orderBy: x => x.OrderByDescending(y => y.Something));