Skip to content

Precompiled queries: support value converters #33541

@roji

Description

@roji

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions