コード例 #1
0
        public void Delete(IHierarchyEntity doc, ITicketAutUser user)
        {
            if (doc?.Id == null)
            {
                return;
            }

            var docColl = CollectionsContainer.GetBsonDocumentContainsId(doc.GetType(), doc.Id.Value);

            if (docColl == null)
            {
                throw new KeyNotFoundException();
            }

            var filter = Builders <BsonDocument> .Filter.Eq("_id", doc.Id);

            var coll = CollectionsContainer.GetMongoCollection(docColl);

            coll.DeleteOneAsync(filter);

            CollectionsContainer.DeleteIdCollection(docColl, doc.Id.Value);

            Auditor?.AuditOperation(OperationType.Delete, doc, user);
        }