I am completely lost on this one. I have a piece of code that does what I need when implemented like this:
return filters.Add(m => m.Metadata.RecordId).IsEqualTo(1);
where m is a TestObj
class object and Add
method's argument is Expression<Func<TestObj,bool?>>
.
Now the problem is that I cannot hardcode m.Metadata.RecordId inside Add, because what I get here is a string that informs me about the property that should be used, in this case "Metadata.RecordId". what I need to do is to construct such an expression with this string that will do the same thing as m => m.Metadata.RecordId does. I need something like this:
string propertyName = "Metadata.RecordId";
Expression expr = null;//create expression here somehow that will do the same as m => m.Metadata.RecordId
return filters.Add(expr).IsEqualTo(1);
How do I do that?