/// <summary> /// Deletes the entity with the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="fireEvents">if set to <c>true</c> fire events.</param> public virtual void Delete(TId id, bool fireEvents = true) { DeletingEntityEventArgs args = null; if (fireEvents) { var existing = Get(id); args = new DeletingEntityEventArgs { Entity = existing }; Fluidity.OnDeletingEntity(args); if (args.Cancel) { return; } } DeleteImpl(id); if (fireEvents) { Fluidity.OnDeletedEntity(args); } }
public void Delete(object id, bool fireEvents = true) { DeletingEntityEventArgs args = null; if (fireEvents) { var existing = Get(id); args = new DeletingEntityEventArgs { Entity = existing }; Fluidity.OnDeletingEntity(args); if (args.Cancel) { return; } } var query = new Sql(_collection.DeletedProperty != null ? $"UPDATE {_collection.EntityType.GetTableName()} SET {_collection.DeletedProperty.GetColumnName()} = 1 WHERE {_collection.IdProperty.GetColumnName()} = @0" : $"DELETE FROM {_collection.EntityType.GetTableName()} WHERE {_collection.IdProperty.GetColumnName()} = @0", id); Db.Execute(query); if (fireEvents) { Fluidity.OnDeletedEntity(args); } }
public static void OnDeletingEntity(DeletingEntityEventArgs args) { DeletingEntity?.Invoke(null, args); }