This is a migrated thread and some comments may be shown as answers.

InvalidOperationException using GridViewColumnExpression on collection

1 Answer 49 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Enrico
Top achievements
Rank 1
Enrico asked on 19 Apr 2013, 03:12 PM

Hi,

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?


1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Apr 2013, 07:10 AM
Hi,

 
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>.

Greetings,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DomainDataSource
Asked by
Enrico
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or