BsonElement attribute is ignored on Id properties

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Serialization
    • None
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      It seems that the `BsonElement` attribute is ignored on properties called "Id". I think this could happen because of our automatic Id recognition.

      For example :

      var pipeline = new EmptyPipelineDefinition<Movie> ()
          .Project(
              Builders<Movie>.Projection
                  .Exclude(m => m.Id)
          );
      
      public class Movie
      {
          [BsonElement("notId")]
          public ObjectId Id { get; set; }
      }

      This will render to

      { "$project" :{ "_id" : 0 }}

      instead of 

      { "$project" :{ "notId" : 0 }}

              Assignee:
              Unassigned
              Reporter:
              Ferdinando Papale
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: