Skip to content

Metadata and type mapping support for primitive collections #30730

Closed
@roji

Description

@roji

Primitive collection support has been implemented in query, along with basic type mapping support. However, we still need to complete the metadata and type mapping story for this:

  • We're lacking metadata APIs to allow the user to configure the element type in the collection. This includes stuff like setting the store type, the requiredness, etc.
  • Currently, every provider implements its own FindCollectionMapping in its TypeMappingSource, checking whether the CLR type is an IEnumerable, and building and cloning a type mapping for the collection. We may be able to move some common logic to core/relational.
    • In fact, we should consider mapping collections to JSON by default, without the provider needing to actually do anything. Note that this means storage only - no querying (which requires provider-specific logic).
  • When doing type inference for constant and parameter query roots, we detect the type mapping of their elements based on later usage, and need to resolve the collection type mapping for that element mapping. This is currently done by instantiating a new type mapping instance, in the provider's type inference code - not great. We should be able to find collection type mapping via TypeMappingSource by providing the collection CLR type and element type mapping.
    • Once this is done, make the type converter comparison a simple reference comparison again rather than an Equals comparison, see QuerySqlGenerator.VisitSqlParameter.

See related #30677, which is about add APIs for how JSON serialization and value extraction should happen.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions