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

SELECT lambda

3 Answers 102 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mattias
Top achievements
Rank 1
Mattias asked on 13 Jun 2011, 07:53 AM
Are you planning on supporting the Select statement, we are having problems when trying to run an aggregate on a child collection property? Or is there any other way around this?

Class B
{
 int Age
}

Class A
{
List<B> children
}

Expression:
Average( a.children.select( c=> c.Age) )


brgds

/mattias

3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 13 Jun 2011, 09:19 AM
Hi Mattias,

 You'll need to form your expression like so: "Average(Children.Select(Age))". Lambdas in the RadExpressionEditor syntax lack the "x => x." part of the C# syntax. Instead, identifiers are automatically resolved in the context of the lambda's parameter.

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mattias
Top achievements
Rank 1
answered on 13 Jun 2011, 10:28 AM
Perfect!

What other methods does the ExpressionEditor support, is the Cast<T>() operator supported, the problem we are facing is that we have an object (which is a double) that we want to take an Average of.

Average(articles.items.Select(Source.Columns[1].DataValue)) // does not seem to work as DataValue is of type object

Do you have any suggestions on how we may cast: Source.Columns[1].DataValue to a double?

Is there any documentation over which expressions that are supported?

/Mattias
0
Accepted
Yavor Georgiev
Telerik team
answered on 13 Jun 2011, 11:51 AM
Hello Mattias,

 Generally, collections in RadExpressionEditor are treated as IQueryable (you can see that in the LambdaExpression the editor produces). Consequently, all the Queryeable extensions methods are support, except for those such as Cast<T>(), which require a type argument. We don't have plans to implement support for calling generic methods in the ExpressionEditor, but we will consider making it possible to cast values.

 Unfortunately, the only thing I can suggest right now is to add properties or methods on your model class that can expose the DataValue property as a double.

 We will release thorough documentation of the expression parser with our Q2 beta release, which should be out in a couple of weeks.

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ExpressionEditor
Asked by
Mattias
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Mattias
Top achievements
Rank 1
Share this question
or