英文:
How to pass orderby parameter value to a lambda function?
问题
Sure, here's the translation of the code snippet you provided:
_unitOfWork.GetAll(/*请在这里传递orderBy参数*/);
Please note that I've kept the code part unchanged and only translated the comment.
英文:
I am using this pattern </br>
https://gist.github.com/pmbanugo/8456744#file-ientityrepository-cs </br>
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
得分: 1
使用命名参数仅传递 orderBy
参数与排序函数。
_unitOfWork.GetAll(orderBy: x => x.OrderByDescending(y => y.Something));
英文:
Use named arguments to only pass the orderBy
argument with a sorting function.
_unitOfWork.GetAll(orderBy: x => x.OrderByDescending(y => y.Something));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论