Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5216

LINQ3: GetType() comparison on document field

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Dotnet Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Hello,

      I'm using GetType on a document field and it works but I've found it translates to a check against every level of the type hierarchy. Usually when you do an OfType style filter it only checks for the last type discriminator if the _t field is an array (for document types):

          {"$match": {"_t": "SomeOrg.SomeType"}}

      but for the subfield it translates to:

          {"$match": {"Field._t":

      { "$size": 3 }

      , "Field._t.0": "SomeOrg.Base", "Field._t.1": "SomeOrg.Parent", "Field._t.2": "SomeOrg.Derived" }}

      The above also seems unable to leverage an index on "Field._t" whereas the first one can.

      Is this intentional? The translator looks to have been added in CSHARP-4691 and there's a comment on the source ("don't match subclasses") that suggests it's just meant to be testing the final discriminator like the other type comparisons instead of the full array.

      Many thanks

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            alistair.steele@trapdoorlabs.uk Alistair Steele
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: