I have an IQueryable and an object of type T.
I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName))
so ...
public IQueryable<T> DoWork<T>(string fieldName)
where T : EntityObject
{
...
T objectOfTypeT = ...;
....
return SomeIQueryable<T>().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName));
}
Fyi, GetProperty isn't a valid function. I need something which performs this function.
Am I having a Friday afternoon brain melt or is this a complex thing to do?
objectOfTypeT I can do the following ...
var matchToValue = Expression.Lambda(ParameterExpression
.Property(ParameterExpression.Constant(item), "CustomerKey"))
.Compile().DynamicInvoke();
Which works perfectly,now I just need the second part:
return SomeIQueryable().Where(o => o.GetProperty(fieldName) == matchValue);