I need to create a LINQ To SQL statement at run time based on user input, and I cannot figure out how to dynamically build a WHERE clause.
I have no problem with the following:
string Filters = "<value>FOO</value>";
Where("FormattedMessage.Contains(@0)",Filters)
But I really need to make the whole WHERE clause dynamic. This way, I can add several conditions at runtime (rough idea):
foreach (Filter filter in filterlist)
{
whereclause = whereclause + "&& formattedmessage.contains(filter)";
}
source
share