You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered: