Simple query generate $expr and the query do not use the index

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.1.1
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      For a very simple odata query the package is generating a query that is not optimal.

      EDM (Datamodel)

       

      var odataBuilder = new ODataConventionModelBuilder();
      odataBuilder.EntitySet<LoanApplicationInfo>("LoanApplications").EntityType.HasKey(c => c.Id);
      

       

      Entity class:

      [BsonIgnoreExtraElements]
      public class LoanApplicationInfo {  
          [BsonId]
           public Guid Id {get; set; }
          public long? CustomerId {get; set; }
      }
      

       

      Odata Query:

      odata/LoanApplications/?$filter=CustomerId eq 22939306348126208&$select=Id, CustomerId

      This is the Generated Query:

      MongoDB.Command: Debug: 1 9 prod-cluster-shard-00-01.yuqul.mongodb.net 27017 11616 27 1 Command started aggregate customers { "aggregate" : "LoanApplicationInfo", "pipeline" : [{ "$match" : { "$expr" : { "$eq" : [{ "$eq" : ["$CustomerId", 22939306348126208] }, true] } } }, { "$project" : { "_id" : 1, "CustomerId" : 1 } }], "cursor" : { }, "$db" : "customers", "lsid" : { "id" : { "$binary" : { "base64" : "rDBGrb0NR/mus35YhhCIwg==", "subType" : "04" } } } }

              Assignee:
              Oleksandr Poliakov
              Reporter:
              Israel Garcia
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: