Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-159

Bson Representation can not be applied to properties with ValueConverters

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • 8.2.2
    • Affects Version/s: None
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      A property can be defined as having a Bson Representation:

      mb.Entity<Customer>().Property(e => e.Value).HasRepresentation(BsonType.Decimal128); 

      And it can also be defined as having a ValueConverter

      mb.Entity<Customer>().Property(e => e.Value).HasConversion<Decimal128>(); 

      However if you use these two features together the Bson Representation is silently dropped.

      mb.Entity<Customer>().Property(e => e.Value).HasConversion<Decimal128>().HasRepresentation(BsonType.Decimal128); 

      Will store the vaule as a string (the default for Decimal128).

      This scenario is likely uncommon but should be fixed. ValueConverterSerializer will need to be extended to support IRepresentationConfigurable and IRepresentationConverterConfigurable.

       

            Assignee:
            damien.guard@mongodb.com Damien Guard
            Reporter:
            damien.guard@mongodb.com Damien Guard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: