its possible to store Where condition in this linq statement in variable?
Func<NutritionValues, bool> condition;
if (isBarcode)
condition = f => f.barcode == name;
else
condition = f => f.food == name;
var foods = context.NutritionValues.Where(condition).
Select(f => new SerializableFood
{
Name = f.food,
Calories = f.energy_kcal,
Carbohydrates = f.carbohydrates,
Fats = f.fats,
Proteins = f.protiens
});
Condition is 100% right. If I write condition f => f.barcode == name
directly into the Where function it works, but this way not. This code return empty set. Please, do you know why?