У меня есть следующий объект в моих моделях:
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Name")]
[BsonRepresentation(BsonType.String)]
public string Name { get; set; }
[BsonElement("Price")]
[BsonRepresentation(BsonType.Double)]
public double Price { get; set; }
[BsonElement("Type")]
[BsonRepresentation(BsonType.Array)]
public string[] Type { get; set; }
, когда я пытаюсь вставить новый объект в базу данных, используя =>
MongoCollection.InsertOne (object);
возникает следующая ошибка
System.TypeInitializationException: The type initializer for 'OrdisTT.Libs.MongoLib' threw an exception.
---> System.ArgumentException: GenericArguments[0], 'System.Array', on 'MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`1[TValue]' violates the constraint of type 'TValue'.
---> System.TypeLoadException: GenericArguments[0], 'System.Array', on 'MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`1[TValue]' violates the constraint of type parameter 'TValue'.
at System.RuntimeTypeHandle.Instantiate(Type[] inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
Как сопоставить свойство массива с массивом mongodb?