I am new to LINQ. I need to perform dynamic operations which seems to be done either with expression trees, or dynamic library. I chose to use System.Linq.Dynamic since it is faster(at this point). I looked up around but nothing seems to help address my issue. I saw several stack post on the same issue but even after changing my code to that it still not resolved.
I am passing two strings(column name, search parameter) to my controller which will execute query and return JSON object. Column name and search parameters have to be dynamic.
The SQL query i need to execute:
SELECT top 50 c1, c2, c3
FROM TableName
WHERE column_name LIKE '%search_parameter%';
var result = db.TableName
.Where("@0.Contains(@1)", column_name, search_parameter)
.Select("new(c1, c2, c3.)");
For now i just want to select select those specific columns ill worry about top 50 later.
I tried also reading through examples on System.Linq.Dynamic but i think i am lacking the basic knowledge i need to understand a lot of the content. I would appreciate some pointers. Thank you.