我有以下使用MongoDb 2.0 c# driver实现的代码。但是我需要访问将被插入的MailLists
集合。Profile
我已经在构造函数中使用了预期的解决方案p
,但是如何通过多个操作来实现它?
IMongoCollection<Profile> dbCollection = DetermineCollectionName<Profile>();
var filter = Builders<Profile>.Filter.In(x => x.ID, profiles.Select(x => x.ID));
var updateMl = Builders<Profile>.Update.AddToSet(p => p.MailLists, new Profile2MailList
{
MailListId = maillistId,
Status = p.MailLists.MergeMailListStatuses(),
SubscriptionDate = DateTime.UtcNow
});
dbCollection.UpdateManyAsync(filter, updateMl, new UpdateOptions { IsUpsert = true });