The simplest way to make this work is to use dynamic
:
row = row.Without((dynamic)expr);
Since row
is already statically typed, the dynamic behavior will be contained to only this statement.
If you didn't want to use dynamic
, you would need to use reflection to invoke the Without
method with the right type parameters, but I don't see any advantage in doing that (it's more complicated, but it isn't any more type-safe).