How can I parse a Linq query?
-
Thursday, April 01, 2010 3:22 AM
Hi,
I need to parse the Linq (.Net Framework 4) command in my system and it must be done at runtime. My desire is get the Linq as string and transform it in an actual code. As example, in my system I need to create a report, this is a runtime procedure, and the user selects the fields and has a "Where" selection. She types:
From s in Database
Where City contains "AB" && Country == "USA"
Select City, Zip, NameThe code above is typed in a text editor. Now the system must parse it and send the result to the report creator.
How can it done?
Thanks,
Marco Castro
All Replies
-
Thursday, April 01, 2010 1:33 PMModerator
Hello Marco,
Glad to see you again!
This question is very interesting. If you want the user to input some LINQ query like we do in LINQPad, we may need .NET CodeDOM to help us compile and run the LINQ query during runtime. For some sample codes, I would recommend you the sample VBCodeDOM in All-In-One Code Framework, which is an open-source project owned by MSDN support team.
Besides, you can also consider letting the user just input some key information, like the filter in WHERE clause and the return result in SELECT clause. If so, the Dynamic LINQ Library can help us to build the LINQ query.
In addition, Entity SQL is another choice if we let the user input some key information.
If you have any questions, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Proposed As Answer by Michael Sun [MSFT]Microsoft Employee, Moderator Tuesday, April 06, 2010 1:31 AM
- Marked As Answer by Michael Sun [MSFT]Microsoft Employee, Moderator Monday, April 12, 2010 6:07 AM
-
Thursday, April 08, 2010 1:14 AMModerator
Hello Marco,
How is the problem? If you need any further assistance, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Monday, April 12, 2010 11:56 AM
Hi Lingzhi,
The data you sent me totally met my needs.
Thanks,
Marco Castro
-
Friday, March 04, 2011 4:46 PM
Hi Lingzhi,
The data you sent me totally met my needs.
Thanks,
Marco Castro
I know it's a long time since the last post, but which part of Lingzhi's post did you end up using? -
Saturday, March 05, 2011 2:38 AMModerator
It's really long time. :)
Do you encounter any similiar issues? If so, could you please open a new thread and let me know the thread link? I will do my best to help.
Have a nice weekend!
Thanks
Michael Sun [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft

-
Wednesday, May 18, 2011 2:08 PM
Hi Michael,
I didn't noticed your last posts, sorry. To tell you the truth, I ended up with none of the solutions. I'm stuck in the development of the new application. There are so many options that it is difficult to decide which one to use. In the future I'll use the runtime compiler so the user can create a Linq query in runtime and send it's data to a report. This is my desire.
Thank you very much for your keeping help.
Marco Castro

