arrays - MongoDB.Driver.MongoWriteException:'写入操作导致错误。无法索引并行数组'
问题描述
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Prop01")]
public int Prop01{ get; set; }
[BsonElement("Prop02")]
public int Prop02{ get; set; }
[BsonElement("Prop03")]
public string[] Prop03{ get; set; }
[BsonElement("Prop04")]
public List<Test> Prop04{ get; set; }
我正在使用 C#(Dot Net Core)在 mongoDB 中插入上述结构/模型,但我收到以下异常:
**MongoDB.Driver.MongoWriteException: '写入操作导致错误。无法索引并行数组 [Prop03] [Prop04]'
内部异常 MongoBulkWriteException`1:批量写入操作导致一个或多个错误。无法索引并行数组 [Prop03] [Prop04]**
我不知道我收到上述异常的原因。
我已经尝试了与前两天不同的技巧,但没有成功。
解决方案
终于问题解决了!
我在并行的数组和列表字段上应用数据库索引,这在 MongoDB 中是不允许的。
推荐阅读
- npm - 如何在 npm 安装期间修复 node-gyp 错误
- google-cloud-platform - Google Cloud Instance Groups - 实例组没有附加后端服务
- python - 熊猫日期时间图
- java - 使 Timepicker 更小
- javascript - 未捕获的 SyntaxError:await 仅在异步函数中的异步函数中有效
- telegram - 如何使用非电报事件触发器发送 Telethon 消息
- wso2 - WSO2 身份服务器:在负载均衡器后面形成 OIDC 端点 URL
- c# - 子对象未在父对象上实例化
- wso2 - WSO2 AM 2.1.0 到 2.6.0 迁移问题 JMSException
- javascript - 从其他数组中删除完全匹配的数组