I have this Bson model in mongodb:
"setting|resources" : {
"Name" : "EsupHamrah",
"Id" : "449ea0e1-0261-4bee-b096-a838746c94ea",
"Children" : [..
I have created this contract model :
public class SettingResources
{
public string Name { get; set; }
[BsonElement]
//[BsonRepresentation(BsonType.String)]
public string Id { get; set; }
//[BsonId(IdGenerator = typeof(CombGuidGenerator))]
//public string Id { get; set; }
public IList<object> Children { get; set; }
}
When i do query I got tthis error:
An error occurred while deserializing the configs property of class ConsoleMongoApp.Applications: An error occurred while deserializing the values property of class ConsoleMongoApp.Configs: An error occurred while deserializing the resources property of class ConsoleMongoApp.Values: Element 'Id' does not match any field or property of class ConsoleMongoApp.SettingResources.
The Id
is just string, not GUID or ObjectId but why mongo can not do map the id?
[BsonRepresentation(BsonType.String)]
.With this i still got above error. – Cyrus the GreatId
element. – Cyrus the Great[BsonIgnoreExtraElements]
for testing and error was gone but i got id = null; – Cyrus the Great