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

Problem evaluating variabel expression in lambda expressions

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.0.1
    • Component/s: API
    • None

      I have a trouble with my code, using mongodb c# driver. This trouble looks like the one described here : http://www.ciiycode.com/0iiBNWWexjex/how-to-update-items-in-an-arraylist-with-mongo-c-driver.html which seems to have been solved.

      I want to update a bi-dimensionnal array in my document. If I use

      myarray[0,3]
      it works, however if I use variable like

      int a = 0;
      int b = 3;
      myarray[a,b]
      it gives me a "Unable to determine the serialization information for the expression ..." error

      Full code :

      int a = 0;
      int b = 3;    
      var update = Builders<sensorValuesDocument>.Update                  
                          .Set(e => e.values[a][b]
                          , new sensorValues()
                          {
                              v = 0,
                              t = 0,
                              h = 0,
                              c = 0,
                              l = 0
                          }) ...
      

      and my document class :

      public class sensorValuesDocument
          {
              ...
              public List<List<sensorValues>> values { get; set; }
              ...
          }
      
       public class sensorValues
          {
              [BsonRepresentation(BsonType.Double, AllowTruncation = true)]
              public float? t { get; set; }
              [BsonRepresentation(BsonType.Double, AllowTruncation = true)]
              public float? v { get; set; }
              [BsonRepresentation(BsonType.Double, AllowTruncation = true)]
              public float? h { get; set; }
              [BsonRepresentation(BsonType.Double, AllowTruncation = true)]
              public float? l { get; set; }
              [BsonRepresentation(BsonType.Double, AllowTruncation = true)]
              public float? c { get; set; }
          }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            JulienS Julien [X]
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: