winforms - Combobox "Select All" in linq query -


i have multiple comboboxes pass value linq query. handling

    if(combobox.text == "select all")        {combobox.text = "") 

and using startswith(combobox.text) method comparison, know wrong. since "jim" return "jimmy". how select when "select all" selected?

the best conditionally add query filter:

var query = datasource.foo.asqueryable(); //you may or may not need asqueryable() depending on "foo" //if not queryable, may need asenumerable(), or nothing  if (!combobox.text.equals("select all"))     query = query.where(x => x.equals(combobox.text));  return query.tolist(); 

the "simpler" way use boolean or, resulting query uglier , may or may not translatable sql (if using):

var query = datasource.foo     .where(x => combobox.text.equals("select all") || x.equals(combobox.text)); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -