I have a document which contains an array as in this simplified example:
{
_id: xxxxxx;
Layers: [{
Chart: "a string value"
}]
}
Somehow in the database, I ended up with an undefined value and am now getting this error when I try to deserialize:
An error occurred while
deserializing the Layers property of class MyApp.Container: An error occurred while
deserializing the Chart property of class MyApp.Layer: Cannot deserialize string from
BsonType Undefined.
The C# classes are like this (simplified here for brevity):
public class Container
{
public List<Layer> Layers { get; set; }
}
public class Layer
{
public string Chart { get; set; }
}
I'm wondering if under these conditions it is even possible for
undefined to be written to the database by the C# driver for a string value or if I should look elsewhere for the cause of
undefined showing up in the db.
Potentially useful info: The mongo shell says the value is
null, but the MongoVUE client shows it as
undefined. The error I'm getting is consistent with it being
undefined.
I am using version 1.7 of the C# driver.