Skip to content

Cosmos: Switch the default discriminator property to $type #34269

@roji

Description

@roji

Our current discriminator property in JSON is called Discriminator; but an emerging semi-standard is for $type to be used as the discriminator property (e.g. S.T.Json's polymorphism support); aligning with that would increase the interoperability of documents produced by default by EF with other JSON tools. Given that we're already introducing lots of breaking changes in the Cosmos provider in 9.0, we should do this one as well.

Notes:

  • The Cosmos LINQ provider does not support inheritancei n any direct way; that is, you can tell it to query for a particular CLR type (which may extend another), but it does not have any concept of a discriminator and does not inject discriminator checks into the queries it generates. It's up to the user to do that manually if they desire.
  • Confirm with the Cosmos team that this all makes sense from their perspective (and i.e. doesn't conflict with future plans for their own LINQ provider or whatever).
  • Note that we have two discriminator concepts: one to identify the concrete type in a hierarchy (our regular concept), and another root-only discriminator for when it's integrated into the JSON id property; this is to allow using ReadItem for that scenario (i.e. so that we don't need to know the precise concrete type in order to construct the JSON ID property for ReadItem). The $type discriminator property discussed in this issue should most likely always contain the regular, concrete discriminator value only.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions