I am aware of few efforts in constructing Linq queries dynamically, such as this, and this.
None seem to be ideal as I would like to avoid putting expressions in a string, and omitting a where if it is not needed.
My main concern is that the query is optimized for the database, and dynamically omits unnecessary clauses whenever possible.
Are there any new developments in EF 4.0 for such scenarios?
UPDATE
here is one link i found very helpful: http://www.albahari.com/nutshell/predicatebuilder.aspx indeed, adding "And" filters dynamically is trivial, and adding "Or" filters can be done easily using predicate builder:
var predicate = PredicateBuilder.False<Product>();
predicate = predicate.Or (p => p.Description.Contains (temp));
and according to LinqPad the sql gets emitted accordingly to what filters were applied..