Consider this snippet of code:
var iList = new List<Entities.Ingredient>
{
new Entities.Ingredient { Name = "tomato", Amount = 2.0 },
new Entities.Ingredient { Name = "cheese", Amount = 100.0 }
};
var matches = new DataContext().Ingredients.Where(i => Comparer(i, iList));
private Boolean Comparer(Entities.Ingredient i, List<Entities.Ingredient> iList)
{
foreach (var c in iList)
{
if (c.Name == iList.Name && c.Amount >= iList.Amount) return true;
}
return false;
}
Is there a more efficient way of doing this? Preferably without being too verbose; from x in y select z... If thats at all possible.