I believe there is a better way to write this but I am experiencing a mental block.
int num = 0;
using(var db = new TestDB())
{
num = db.Table.Where(x => x.FavoriteSport == "Baseball" &&
(x.FavoriteColor == "Green" ||
x.FavoriteColor == "Blue" ||
x.FavoriteColor == "Red")).Count();
}
return num;
Is there a better way to write the OR
statements? I have tried:
x.FavoriteColor == "Green" || "Blue" || "Red"
but the compiler says Operator || cannot be applied to operands of type 'bool' and 'string'
Any help is appreciated.