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

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

4 Answers 376 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 16 Aug 2011, 08:06 PM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 16 Aug 2011, 08:41 PM
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 >>

0
Shiva
Top achievements
Rank 1
answered on 17 Aug 2011, 07:25 AM
Dear Yavor,

That did the trick. Thank so you much.

Warm Regards,
Shiva
0
Mallikarjun
Top achievements
Rank 1
answered on 25 Aug 2011, 12:41 PM
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
0
Dimitrina
Telerik team
answered on 25 Aug 2011, 04:58 PM
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 >>

Tags
ExpressionEditor
Asked by
Shiva
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Shiva
Top achievements
Rank 1
Mallikarjun
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or