InvalidOperationException using GridViewColumnExpression on collection

2 posts, 0 answers
  1. Enrico
    Enrico avatar
    6 posts
    Member since:
    Dec 2012

    Posted 19 Apr 2013 Link to this post


    we are using a GridView to display our items properties. Additionaly we show some calculated properties that are stored as historical data - we want to show the latest of them. By the showing these properties is not our problem. We want to filter for them.

    In our codebehind file we set expression:
    Expression<Func<Entity, string>> expr = (a) => a.HistoryEntries.OfType<SomeKind>().OrderByDescending(h => h.ValidFrom).FirstOrDefault().My.Prop;

    By filtering we get the error message that there is no generic method "OrderByDescendig" on type "System.ServiceModel.DomainServices.Client.EntityQueryable".
    First Lines of stack trace are:

    System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)

       bei System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)

       bei Telerik.Windows.Controls.DomainServices.EntityQueryPlaceholder`1.EntityQueryBuilder.VisitMethodCall(MethodCallExpression node)

       bei System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)

    Do you have any suggestions how to handle this case for filtering?

  2. Rossen Hristov
    Rossen Hristov avatar
    2477 posts

    Posted 22 Apr 2013 Link to this post


    You can filter and sort only on properties that actually exist on the server because ultimately your query will reach SQL Server and will be executed there. This is how WCF RIA Services work. You should get exactly the same exception if you filter manually by using the DomainContext.Load method and the EntityQuery<T>.

    Rossen Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top