Linq with optional WHERE options
问题 I have a .Net function that accepts 3 parameters, all optional. Something like this: public List<MyObject> Search(string colour, string size, string name) { var result = (from c in MyTable where .... select c).ToList(); } My question is, what is the best way to do the where part. Would the best be to create dynamic linq? What's the best pattern, within linq, to have optional where parameters? So, in SQL, something like this: SELECT * FROM MyTable WHERE (@colour <> '' AND colour = @colour) AND