Linq.Expression.Optimizer icon indicating copy to clipboard operation
Linq.Expression.Optimizer copied to clipboard

[Feature Request] Generic Type parameter for Expression in visit method

Open SpaceOgre opened this issue 3 years ago • 1 comments

Description

It would be nice if the visit method got a generic type overload, so I don't have to cast the expression returned.

return (Expression<Func<Models.Organisation.EducationEvent, bool>>)ExpressionOptimizer.visit(expression);

Not sure how it would look in F# but something like this in C#

public Expression<T> visit<T>(Expression<T> expression)

SpaceOgre avatar Sep 23 '22 14:09 SpaceOgre

I was looking this at some point, but the typical way of working with Linq expression trees is that they are visited and re-constructed recursively, and there is no easy way to carry the generic type parameters through-out the full expression tree traversal, so some level cast has to happen anyway. That's why I thought it's probably better that the user explicitly does it.

Thorium avatar Mar 08 '23 13:03 Thorium

I decided to add this anyway, as visitTyped.

Thorium avatar Jun 26 '24 13:06 Thorium