Rock.Model.HistoryService.DeleteChanges C# (CSharp) Method

DeleteChanges() public static method

Deletes any saved history items.
public static DeleteChanges ( RockContext rockContext, Type modelType, int entityId ) : void
rockContext Rock.Data.RockContext The rock context.
modelType System.Type Type of the model.
entityId int The entity identifier.
return void
        public static void DeleteChanges( RockContext rockContext, Type modelType, int entityId )
        {
            var entityType = EntityTypeCache.Read( modelType );
            if ( entityType != null  )
            {
                var historyService = new HistoryService( rockContext );
                foreach( var history in historyService.Queryable()
                    .Where( h =>
                        h.EntityTypeId == entityType.Id &&
                        h.EntityId == entityId ) )
                {
                    historyService.Delete( history );
                }

                rockContext.SaveChanges();
            }
        }