You can do this in two ways, one way is to create an expression using expression trees (necessary for IQueryable situations). But since you are querying the model in memory, you can save the list of predicates and use the extension Anyto filter.
var predicates = new List<Func<XElement, bool>>();
for (int i = 1; i < chkBx.Count(); i++)
{
if (chkBx[i].Checked)
{
var match = chkBx[i].Text;
predicates.Add(el => (string)el.Parent.Element("Diameter") == match)
}
}
selectedElements = selectedElements.Where(el => predicates.Any(p => p(el)));
source
share