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

Cannot hide base property

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • BSON, Json.NET
    • None
    • Net Core 3.1

    Description

      Hi everyone,

      I'm currently stuck in this situation:

      class A
      {
          public DateTime CreatedOn \{ get; set; }
      }
       
      class B : A
      { 
          public new DateTimeOffset CreatedOn \{ get; set; }
      }
      

      Every time I try to get an IMongoCollection<B> I get this error:

      MongoDB.Bson.BsonSerializationException: 'The property 'CreatedOn' of type 'B' cannot use element name 'CreatedOn' because it is already being used by property 'CreatedOn' of type 'A`1.
      

      Is there any way to get around this problem?

      Thank you in advance,

      Luca

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            lbellavia@technogym.com Luca Bellavia
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: