Home > Net > Lambda expressions in c # dynamic field
Lambda expressions in c # dynamic field
Time:10-10
Front a drop-down box, have, time and ID two sorting options, and then I choose any options, ordered by the field name of any options For example List The userList=userList. OrderBy (a=& gt; Anderson, d). ToList (); Which can dynamically modify field, Anderson d ordered by the field name of the
List The userList=userList. OrderBy (a=& gt; A. (dynamic parameters). ToList ();
CodePudding user response:
With expression trees or reflection, Reflect a simpler, List The userList=userList. OrderBy (a=& gt; Al-qeada etType (.) GetProperty (" field name "). The GetValue (a, null). The ToString ()). ToList ();
CodePudding user response:
According to the parameters sorted with just switch With reflective do more harm than good, and if it is EF? How do you counter