[CSHARP-1318] Problem evaluating variabel expression in lambda expressions Created: 15/Jun/15  Updated: 16/Jun/15  Resolved: 16/Jun/15

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.0.1
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Julien [X] Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-1246 Not partially evaluating FieldDefinit... Closed

 Description   

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; }
    }



 Comments   
Comment by Craig Wilson [ 16/Jun/15 ]

Hi Julian.

This will be fixed in 2.0.2 / 2.1. I've linked to CSHARP-1246.

Craig

Generated at Wed Feb 07 21:39:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.