我尝试Official Mongo c# 2.0 driver
通过以下代码执行批量更新操作:
var query =
Builders<Profile>.Filter.In(p => p.userId, listBounce.Values.ToList()) &
Builders<Profile>.Filter.In(p => p.ID, listBounce.Keys.Select(x=> new ObjectId(x)).
ToList());
var update = Builders<Profile>.Update.Set(p => p.MailLists[-1].Status, (int)wrongEmailStatusAssetId);
dbCollection.UpdateManyAsync(query, update).Wait();
但是出现了以下错误
{"A write operation resulted in an error.\r\n
The positional operator did not find the match needed from the query.
Unexpanded update: p2l.$.status"}
我需要更新与查询匹配的数组中每个元素的属性。文件结构为:
{
"_id" : ObjectId("55eeb5da965bb036984110b9"),
"created" : ISODate("2015-09-08T10:17:59.784Z"),
"userId" : 13929,
"email" : "go-get@yandex.ru",
"firstName" : "Skrillex",
"lastName" : "Skrillex",
"phoneNumber" : "",
"isUnsubscribed" : false,
"isAboveLimit" : false,
"status" : 0,
"userAgent" : 9760,
"isDeleted" : false,
"p2l" : [
{
"listId" : 45165,
"status" : 131,
"subscriptionDate" : ISODate("2015-09-04T06:24:55.763Z")
}
]
}