c# - How to access OrderBy clause from MethodCallExpression -


i have custom linq provider processes methodcallexpression has orderby clause inside it. how can hold of orderby clause may process it?

i figured out, here how.

    public class querycontext<t>     {         void execute(methodcallexpression dsqueryexpression)         {             var orderbyfinder = new orderbyfinder();             var orderbyexpression = orderbyfinder.getorderby(dsqueryexpression);             // .. continue on processing orderby expression         }     }      internal class orderbyfinder : expressionvisitor     {         methodcallexpression _orderbyexpression;          public methodcallexpression getorderby(expression expression)         {             visit(expression);             return _orderbyexpression;         }          protected override expression visitmethodcall(methodcallexpression expression)         {             if (expression.method.name == "orderby") _orderbyexpression = expression;              visit(expression.arguments[0]);              return expression;         }     } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -