How to handle id element when mapping mongoDB document to C# class -


i want deserialize document looks this:

{      "_id" : objectid("58e67bd8df79507aa3f8a6b6"),      "value" : 10,     "stack" : [         {             "id" : "49ccbadf-5964-11e6-b1e9-549f3520935c",              "value" : 0         },          {             "id" : "49ccb5cc-5964-11e6-b1e9-549f3520935c",              "value" : 0         }     ] } 

to c# class. class name entry , definition looks this:

public class entry {     public bsonobjectid _id { get; set; }     public int value { get; set; }     public list<stack> stack { get; set; } } 

and stack class looks this

public class stack {     public string id { get; set; }     public int value { get; set; } } 

when querying following exception

'an error occurred while deserializing stack property of class consoleapp4.entry: element 'id' not match field or property of class consoleapp4.stack.' 

i can decorate stack class [bsonignoreextraelements] attribute , exception gone don't want since have use id property in querying. has idea should do? appreciate help.

got doing through trial , error - enough decorate stack class [bsonnoid] attribute.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -