0

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*/);

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
Toha
  • 5
  • 3
  • Does this answer your question? [How can you use optional parameters in C#?](https://stackoverflow.com/questions/199761/how-can-you-use-optional-parameters-in-c) – phuzi Jul 18 '23 at 09:03
  • no ! I can't pass argument to a lambda expression type function. which is more complex than what you shared. thanks @phuzi – Toha Jul 19 '23 at 10:49

1 Answers1

1

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

_unitOfWork.GetAll(orderBy: x => x.OrderByDescending(y => y.Something));
nikstra
  • 556
  • 3
  • 9