Skip to content

Enhance InvalidOperationException message fo better cause understaning #24452

@lucacestola

Description

@lucacestola

While writing some complex queries it's easy to face an InvalidOperationException that says that the expression can't not be translated.

Often I find an obvious cause just by taking a better look at a misuse of an untranslatable function or a bad use of a group by. Sometimes, however, it is a little tougher and I start breaking the query into several steps until I find the point where it becomes untranslatable.

This time I ran into a strange situation where applying an OrderBy breaks the query translation and however I tried to simplify or make the query more straightforward, I was unable to get to work. The InvalidOperationException states that the whole Expression cannot be translated, but I guess the engine knows on which part of the expression it fails transalating.

It would be helpful if the exception could suggest which part of the expression caused the problem and, of course, why it couldn't. The exception should be more specific than a System.InvalidOperationException, with at least the specific Expression (or a list of them) where the problem occurred, but it would be better to also have the reason.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions