parse delegate to string query c#.net
I want to implement simple LINQ-to-SQL-like functionality in m开发者_如何学Cy .net application. For example i have the following code:
userAccounts.Where(ua=>ua.Name=="User1");
and i want delegate in Where method to create a string like this
"name = 'User1'".
How it can be done?
Thanks.
The solution you are looking for is called Expression Tree Visitor.
See this blog on how to parse and visualize the query's .Expression property
精彩评论