I have a criteria object in which I was to turn each property into a func, if it\'s value isn\'t null.
public class TestClassCriteria
{
public bool? Colu
Your current expression is comparing the property names, but I think you want to be comparing the property values:
var funcs = new List>();
foreach (var property in criteria.GetType().GetProperties())
{
funcs.Add(x => x.GetType().GetProperty(property.Name).GetValue(x, null) == property.GetValue(criteria, null));
}
However, are you sure you need to do this? There would probably be a better way to refactor your code so that you don't need to use reflection to compare properties that happen to have the same name on two unrelated objects.