dynamically create lambdas expressions + linq + OrderByDescending

前端 未结 2 1275
别那么骄傲
别那么骄傲 2021-01-21 15:24

how can I create a dynamic lambda expression to pass to use in my orderby function inside linq?

I basically want transform queryResults.OrderByDescending();

2条回答
  •  无人及你
    2021-01-21 16:02

    See Dynamic LINQ

    Alternately, you can use a switch statement, Reflection or the dynamic type in C# 4 to return the value based on a supplied field name.

    This has also been done to death previously

提交回复
热议问题