Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompiled queries: support value converters #33541

Open
Tracked by #34446
roji opened this issue Apr 15, 2024 · 1 comment
Open
Tracked by #34446

Precompiled queries: support value converters #33541

roji opened this issue Apr 15, 2024 · 1 comment

Comments

@roji
Copy link
Member

roji commented Apr 15, 2024

We have a general problem with the "quotability" of type mappings. That is, when a type mapping is encountered somewhere when precompiling a query, we need to be able to generate code that finds/creates the same type mapping when the program actually starts up. In the shaper, in most cases we know the type mapping's property, so we can generate a lookup for that property on the model, and get the type mapping from there. But when generating the SQL tree (or the TypeMappedRelationalParameter directly, when pregenerating SQL), we don't have the property, since nodes in the SQL tree only reference the type mapping directly.

At the moment, we're faking it by generating code that simply instantiates the type mapping given the various facets (store type, size...); but this doesn't work for value converters (and comparers). As a short-term solution, we should be able to pass in the value converter directly as a lambda, assuming that lambda is generatable as C# (i.e. doesn't capture some external state). But long-term, we need a more general mechanism for type mapping quotability, where e.g. the type mapping would reference its originating property, so that we can generate a model lookup for that.

/cc @ajcvickers

@maumar
Copy link
Contributor

maumar commented Apr 15, 2024

related: #33517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants