BsonExtraElement query

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Do
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.10.2
    • Component/s: API
    • None
    • None
    • 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

      for this scene

      Here is my model class:

      {{}}

      public class MongoProductEntity 
      {
          public MongoProductEntity()
          {
              AdditionalColumns = new BsonDocument { AllowDuplicateNames = false };
          }
          [BsonExtraElements]
          public BsonDocument AdditionalColumns { get; set; }
          public string BrandName { get; set; }
      }
      

      {{}}{{}}Here is the query part:

       var productEntity = new MongoProductEntity ()
              {
                  BrandName = "Brand"
              };            
              productEntity.AdditionalColumns.Add("testProperty", 6);
              productEntity.AdditionalColumns.Add("testProperty2", "almafa");
      
              await productEntityRepo.InsertAsync(productEntity);
              var qq = productEntityRepo.Where(x => x.AdditionalColumns["testProperty"] == 6).ToList();
      

      a solution is like this

      var filter = Builders<BsonDocument>.Filter.Eq("testProperty2", "almafa");
      productEntityRepo.Where((dbModel) => dbModel.BrandName == "Brand" && filter.Inject());
      

      but this is not friendly

      MongoDb.Driver has many ExpressionVistor,the query like 

      productEntityRepo.Where(x => x.AdditionalColumns["testProperty"] == 6
      

      can be convert to 

      var filter = Builders<BsonDocument>.Filter.Eq("testProperty2", "almafa"); productEntityRepo.Where((dbModel) => dbModel.BrandName == "Brand" && filter.Inject());
      

      in driver internal, this is more important for general queries,to avoid using the above code,that more friendly

       

       

       

       

       

            Assignee:
            Unassigned
            Reporter:
            zeng pu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: