URGENT : How to convert string into System.Linq.Expressions.Expression??

5 posts, 1 answers
  1. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 16 Aug 2011 Link to this post

    Dear Community,

    We have a UI where user can create an expression using telerik expression editor. Now since we would like to show this expression to the user everytime s/he lands up on this page and thus we store the expression in a database table as a string column. We fetch the expression as below:

    string expression = expEditor.Expression.ToString()

    where expEditor is the Expression Editor control on UI.

    Now next time when user opens up the page, we would like to show the saved expression and evaluate it as well then and there.

    For this, we found that "Dynamic Language Runtime" could help us evaulate the expression at runtime. But for that we must have the expression and that too of type "System.Linq.Expressions.Expression" I guess. However in our database, we have it as a string.

    This is where the problem is. We are not able to cast the string value into "System.Linq.Expressions.Expression" so that we can use DLR to evaluate the expression at runtime. We are getting unable to tyoe cast error when we try to do so.

    Please share your comments with us as soon as possible.

    Regards,
    Shiva
  2. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 16 Aug 2011 Link to this post

    Hi Shiva,

     You should use the value of the ExpressionText property instead. You can then use the TryParse extension method (located in the Telerik.Windows.Controls namespace) on RadExpressionEditor to parse the string you saved into a LINQ Expression.

    Greetings,
    Yavor Georgiev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    Dear Yavor,

    That did the trick. Thank so you much.

    Warm Regards,
    Shiva
  5. Mallikarjun
    Mallikarjun avatar
    12 posts
    Member since:
    Jan 2011

    Posted 25 Aug 2011 Link to this post

    Hi,

    I am unable to find the the TryParse  method. I added the "using Telerik.Windows.Controls;" namespace but still couldn't find. Please help.

    PFA of the dll version. 

    Thanks,
    Mallikarjun
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Aug 2011 Link to this post

    Hello Mallikarjun,

    In order to use the TryParse method of the ExpressionEditor, you should upgrade to the latest version of the RadControls(Q2 2011).

    Best wishes,
    Didie
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft banner