I have a generic method:
public void ExpressionBuilder<T>() where T: IEntity
{
Expression<Func<T, long>> expr = e => e.Id; //Id is part of IEntity
...
}
The resulted expression contains casting of T to IEntity: e => Convert(e).Id
I want to remove this casting (to make it possible for EF to generate SQL). In other words I would like to replace Convert(e) by e.
If we assume a
public long Id {get;}onT, and the expression is that simple, then maybe just build it manually:A visitor should work for more complex examples; for example:
and