公式のC#ドライバーを使用して、mongodbのコレクションからいくつかのレコードを削除する必要があります。私のコードは次のとおりです。
public static void Remove(List<ObjectId> objectIds)
{
ObjectMongoCollection.Remove(Query.In("NotificationId", new BsonArray(objectIds)), SafeMode.True);
}
public class Notification
{
public static MongoCollection<Notification> ObjectMongoCollection = MongoHelper.GetMongoServer("MongoKelimeYarisi").GetDatabase("KelimeYarisi").GetCollection<Notification>("Notification");
[BsonId]
public ObjectId NotificationId { get; set; }
public int PlayerId { get; set; }
public string OpponentName { get; set; }
public string gameId { get; set; }
public DateTime CreateDate { get; set; }
public NotificationStatus Status = NotificationStatus.New;
public NotificationType Type = NotificationType.RoundSubmit;
public bool IsPushed { get; set; }
エラーなしで実行されますが、機能していないようです。ObjectIdのリストを使用してレコードを削除するにはどうすればよいですか。
また試した:
ObjectMongoCollection.Remove(Query.In("_id", new BsonArray(objectIds)), SafeMode.True);