SELECT lambda

4 posts, 1 answers
  1. Mattias
    Mattias avatar
    15 posts
    Member since:
    May 2011

    Posted 13 Jun 2011 Link to this post

    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
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 13 Jun 2011 Link to this post

    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
  3. DevCraft banner
  4. Mattias
    Mattias avatar
    15 posts
    Member since:
    May 2011

    Posted 13 Jun 2011 Link to this post

    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
  5. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 13 Jun 2011 Link to this post

    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
Back to Top