Understanding Primary Business Objects

The discussion of primary business objects must begin with an understanding of what business objects should and shouldn't do.

Business Objects Are Mute

Without exception, business objects should not display any messages to the user interface. This is extremely important if you want your business objects to be used in both Windows and Web applications. Although a business object could display a message (using MessageBox, for example) in a WPF application, what happens if you deploy your business object to a Web server? The scenario simply doesn't work.

Business Form Methods

However, there are situations where you want to display a message before a business object performs an action. For example, before deleting a record, you may want to display the message "Are you sure?" Since you don't want the business object's Delete method to display a MessageBox asking this question, how do you accomplish this? Since it's the user interface's job to interact with the user, you can have the UI do it.

The WPF mmBusinessWindow class has the following methods that correspond to methods of the same name on the mmBusinessObject class:

  • CancelEntity
  • DeleteEntity
  • NewEntity
  • SaveEntity

For example, mmBusinessWindow has a DeleteEntity method that first asks the user if they are sure they want to delete the record. If the user selects No, the method simply returns. However, if the user selects Yes, the form-level DeleteEntity() method calls the DeleteEntity() method of a business object which performs the actual deletion.

Calling Business Form Methods

Normally, you can use MM .NET specialized buttons such as mmButtonCancel, mmButtonDelete, mmButtonNew, and mmButtonSave which automatically call these form-level methods for you. However, you can also call these methods manually. For example:

For example, in C#:

this.NewEntity();

And in VB .NET:

Me.NewEntity()

The Primary Business Object

So now the question arises, "If there is more than one business object registered with a form, how does the form know which business object to call? By default, this is the form's primary business object.

You can specify a business object as the primary business object by means of the form's RegisterPrimaryBizObj method.

For example, in C#:

this.RegisterPrimaryBizObj(new Order());

And in VB .NET:

Me.RegisterPrimaryBizObj(New Order())

In this example, the business form methods will call the Order business object before or after ineracting with the user.

Using Business Form Methods with Other Business Objects

At times you may want to use other business objects (non-primary) with business form methods. This is easy to do because each of the form-level methods listed above has an overload that accepts a single mmBusinessObject parameter. This allows you to pass any business object to the form level method and have it used in place of the primary business object.

For example, the following C# code demonstrates passing an OrderItem business object to the form-level DeleteEntity() method:

private void btnDeleteItem_Click(object sender, EventArgs e)
{
	// Delete an order item
	this.DeleteEntity(this.OrderItem, this.OrderItemEntity);
}

And in VB .NET:

Private Sub btnDeleteItem_Click(ByVal sender As System.ObjectByVal e As EventArgsHandles btnDeleteItem.Click
	' Delete an order item
	Me.DeleteEntity(Me.OrderItem, Me.OrderItemEntity)
End Sub

In this example, the form asks the user if they want to delete the record, and then calls the DeleteEntity method of the OrderItem business object.


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/14/18
Comment or report problem with topic