Details
-
Task
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
Description
I have following classes:
public class Property |
{
|
public string Description { get; set; } |
public object Value { get; set; } |
|
|
[BsonExtraElements]
|
public IDictionary<string, Property> OtherData { get; set; } |
}
|
|
|
public class Device |
{
|
public string DeviceId { get; set; } |
public IDictionary<string, Property> Properties { get; set; } |
}
|
What i want to achieve in json and map to those classes, is:
{
|
"DeviceId":"asd", |
"Properties":{ |
"PropertyA":{ |
"Description":"some info", |
"PropertyAB":{ |
"Description":"some info", |
"Value":"etc" |
}
|
},
|
"PropertyB":{ |
"Description":"some info", |
"Value":"etc" |
}
|
}
|
}
|
So, as you can see, i want to map concrete Model "Property" in recursive way with ExtraElements usage. But above code will fail, as BsonExtraElements can be used only with IDictionary<string, object> interface. Also:
public class Property : IDictionary<string, Property> |
{
|
public string Description { get; set; } |
public object Value { get; set; } |
}
|
doesn't work. And to be honest, this semantic would be the most desired. (no need to reach extra Property OtherData) But neither both of those semantics i cannot map properly. Is anyone tried something similar before? Any hints how to achieve this?