Here's my code:
var query = from x in Data
select new { Fruit = x[0], Animal, x[2], Color = x[3], Food = x[4] };
Now, I want to create checkboxes such that if a user checks off "box 1" it will do a different query like so:
select new { Fruit = x[7], Animal, x[4], Color = x[8], Food = x[9] };
My question is, how do I make it so that depending on which checkbox is checked a different select...new statement will be used?
I think I can use multiple if/then statements to see which particular box is checked and to determine which select...new statement to use, but I'm guessing there is a better way out there.
In VB I think a "case" statement would come into play, but I don't know what is the C# equivalent.
My failed attempt at implementing case/switch in the context of changing query parameters:
int caseSwitch = 1;
var query = from x in Data
switch (caseSwitch)
{
case 1:
select new { Fruit = x[0], Animal, x[2], Color = x[3], Food = x[4] };
break;
case 2:
select new { Fruit = x[7], Animal, x[4], Color = x[8], Food = x[9] };
break;
}