SQL Like keyword in Dynamic Linq
Posted
by Erwin
on Stack Overflow
See other posts from Stack Overflow
or by Erwin
Published on 2010-04-27T02:39:16Z
Indexed on
2010/04/27
2:43 UTC
Read the original article
Hit count: 623
Hi fellow programmer
I want to use SQL's Like keyword in dynamic LINQ.
The query that I want to make is like this
select * from table_a where column_a like '%search%'
Where the column_a can be dynamically changed to other column etc
In this dynamic LINQ
var result = db.table_a.Where( a=> (a.column_a.Contains("search")) );
But the column can't be dynamically changed , only the search key can
How do we create a dynamic LINQ like
var result = db.table_a.Where("column_a == \"search\"");
That we can change the column and the search key dynamically
© Stack Overflow or respective owner