Support HasConversion on primitive lists & arrays

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Do
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      We support HasConversion for primitive properties but although the API lets you specify it for a primitive collection we do not perform the conversion in the MongoTypeMappingSource when the property is a collection so if trying to map say a HashSet<string> on a CLR property to a List<string> in the database it will throw with the error messageĀ 

      System.InvalidOperationException: 'The type 'HashSet<string>' cannot be used as a primitive collection because it is not an array and does not implement 'IList<string>'. Collections of primitive types must be arrays or ordered lists.'

      Reported on the community forums https://www.mongodb.com/community/forums/t/invalidoperation-for-hashset-field-even-with-conversion-defined/322555

              Assignee:
              Damien Guard
              Reporter:
              Damien Guard
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: