Override of a Method

The platform provides a way to override a method of a BLC.

Suppose that you need to override the Persist method of the BaseBLC class, which is defined in the code below.

public class BaseBLC : PXGraph<BaseBLC>
{
    public virtual void Persist()
    {
        ...
    }
}
You can override the method within a BLC extension as follows.

public class BaseBLC_Extension : PXGraphExtension<BaseBLC>
{
    public delegate void PersistDelegate();
    [PXOverride]
    public void Persist(PersistDelegate baseMethod)
    {
        ...
        baseMethod();        
        ...
    }
}

The graph extension should include the declaration of the base method delegate, the PXOverride attribute, and the overridden method, which invokes the base method delegate, as the code above shows.

Because the PXOverride attribute on the declaration of the method is included in the graph extension, it forces the system to override the original method in the graph instance. Otherwise, both base and overridden methods will be invoked.