When searching for the linq conditional where condition, I found this article , how they are used is as follows:
var logs = from log in context.Logs select log; if (filterBySeverity) logs = logs.Where(p => p.Severity == severity); if (filterByUser) logs = logs.Where(p => p.User == user);
but I was wondering if this method is effective? How many queries will linq execute?
You can use dynamic LINQ ( ScottGu article )
So, you can easily create a where clause in a string and then pass it to the Where method:
public string GetWhereClause() { string whereClause = ""; .... return whereClause } var logs = context.Logs.Where( GetWhereClause() );
Hope this helps;)
, , . , - "". , (.. WHERE, ).
, LINQ , , , , , . SQL Server Profiler.