Skip to content

Expose way for users to cast to any store type #11921

@roji

Description

@roji

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions