Hope I am asking this question in the right way.
I am trying to determine the most efficient way to use checkboxes to alter what is returned from my linq query without having to code for every possible combination.
As an example, I have three checkboxes on my winform that represent three columns that I am trying to query
[ ] Year
[ ] Make
[ ] Model
I am using a linq statement to determine the distinct combinations of year make and model through EF
var uniquecombos = cb.MakeModelYear.Where(i => i.Year != null && i.Make != null && i.Model != null).Distinct().ToList();
What I would like to do is use the checkboxes on my winform to drive which fields I include in my query.
So
[x] Year
[x] Make
[ ] Model
would yield
var uniquecombos = cb.MakeModelYear.Where(i => i.Year != null && i.Make != null).Distinct().ToList();
Is there a good way to modify the inputs of the query without having to account for every combination of checkboxes through if statements?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire