Example #1
0
        public virtual void Delete <T>(T entity, IDeleteCommandInterceptor deleteStrategy) where T : class
        {
            Check.NotNull(entity, "entity");
            Check.NotNull(deleteStrategy, "deleteStrategy");

            deleteStrategy.Delete(this, Delete, entity);
        }
        protected override void DeleteEntityActioned <T>(T entity, IDeleteCommandInterceptor deleteCommandInterceptor)
        {
            deleteCommandInterceptor.Delete(
                this,
                new Action <T>(p =>
            {
                var bsonValue  = MongoDbOverridables.Instance.GetBsonIdValueFromEntity(entity);
                var mongoQuery = Query.EQ("_id", bsonValue);

                var collectionName = CollectionHelpers.CollectionNameFromEntity(entity);
                var result         = MongoDatabase.GetCollection <T>(collectionName).Remove(mongoQuery, RemoveFlags.Single);
                RaiseEvent(new MongoDbEntityDeletedEvent(this, entity, result));
            }),
                entity);
        }