(previously discussed in npgsql/efcore.pg#315 (comment))
In Npgsql, in some cases the same CLR type can be mapped to several store types. For example, string types are mapped to text by default, but they can also be mapped to json and even citext, PostgreSQL's case-insensitive string data type.
Everything works well for entity properties, where the fluent API can be used to specify the store type. However, the same is missing for other literals, parameters, etc. - users currently seem to have no way to manually specify that a string should be sent as a json or citext parameter rather than as a text. The current casting options all operate on CLR types, but in this case we really have only one CLR type and the cast operation cannot be represented.
To solve this, EF Core could expose an EF.Functions.Cast() which would accept an arbitrary store type, as a string. This would render into a simple SQL cast operation.
/cc @rwasef1830
(previously discussed in npgsql/efcore.pg#315 (comment))
In Npgsql, in some cases the same CLR type can be mapped to several store types. For example, string types are mapped to
textby default, but they can also be mapped tojsonand evencitext, PostgreSQL's case-insensitive string data type.Everything works well for entity properties, where the fluent API can be used to specify the store type. However, the same is missing for other literals, parameters, etc. - users currently seem to have no way to manually specify that a string should be sent as a
jsonorcitextparameter rather than as atext. The current casting options all operate on CLR types, but in this case we really have only one CLR type and the cast operation cannot be represented.To solve this, EF Core could expose an
EF.Functions.Cast()which would accept an arbitrary store type, as a string. This would render into a simple SQL cast operation./cc @rwasef1830