How to Convert a search string into a LINQ Query.
The delimiters are always AND,OR,(,) Say I have search string inputs as:
I want to build a LINQ query based on this. Example Output(for case 3): 1. where value = "pqr" OR value="ter" AND (value="asd" OR value="tor")
How can we achieve these kinds of segregation for a string.
Take a look into System.Linq.Dynamic
. Seems to have the functionality you want.
Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)
Otherwise you can parse the expression yourself and generate an expression tree.
Dynamic LINQ Queries with Expression Trees
https://www.simple-talk.com/dotnet/.net-framework/dynamic-linq-queries-with-expression-trees/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.