Deleting Business Entities
MM.NET business objects have a set of DeleteEntity() and DeleteEntityList() methods that allow you to save a delete a single entity or a list of entities.
If a business object's ImmediateDelete property is false, the entity is simply marked for deletion and is physically removed from the database when you save the entity. If ImmediateDelete is true, the entity is immediately deleted.
Using DeleteEntity() and DeleteEntityList() to Delete Business Entities
The DeleteEntity() method deletes a single entity. The DeleteEntityList() method deletes one or more entities in a list. Both methods return true if the deletion succeeds, otherwise they return false.
Example 1
Here is an example of code that calls DeleteEntity() to delete a single entity.
In C#:
// Retrieve an employee Employee employee = new Employee(); EmployeeEntity employeeEntity = employee.GetEmployeeByPK(employeeID); // Delete the employee var deleteResult = employee.DeleteEntity(employeeEntity); // If the business object's ImmediateDelete property is false, // you must save the entity to delete it from the back end var saveResult = employee.SaveEntity(employeeEntity); if (saveResult != mmSaveDataResult.RulesPassed) { var brokenRules = employee.Rules.GetAllBrokenRules(); }
In VB .NET:
'' Retrieve an employee Dim employee = New Employee() Dim employeeEntity = employee.GetEmployeeByPK(employeeID) '' Delete the employee Dim deleteResult = employee.DeleteEntity(employeeEntity) '' If the business object's ImmediateDelete property is false, '' you must save the entity to delete it from the back end Dim saveResult = employee.SaveEntity(employeeEntity) If saveResult <> mmSaveDataResult.RulesPassed Then Dim brokenRules = employee.Rules.GetAllBrokenRules() End If
Example 2
Here is an example of code that calls DeleteEntityList() to delete a list of entities.
In C#:
// Retrieve a list of employees Employee employee = new Employee(); mmBindingList<EmployeeEntity> employeeEntityList = employee.GetEmployeesByRegion(regionID); // Delete the entities which were stored in the business object's EntityList property var deleteResult = employee.DeleteEntityList(); // If the business object's ImmediateDelete property is false, // you must save the entity list to delete it from the back end var saveResult = employee.SaveEntityList(); if (saveResult != mmSaveDataResult.RulesPassed) { var brokenRules = employee.Rules.GetAllBrokenRules(); }
In VB .NET:
'' Retrieve a list of employees Dim employee = New Employee() Dim employeeEntityList = employee.GetEmployeesByRegion(regionID) '' Delete the entities which were stored in the business object's EntityList property Dim deleteResult = employee.DeleteEntityList() '' If the business object's ImmediateDelete property is false, '' you must save the entity list to delete the entities from the back end Dim saveResult = employee.SaveEntityList() If saveResult <> mmSaveDataResult.RulesPassed Then Dim brokenRules = employee.Rules.GetAllBrokenRules() End If
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 06/26/18
Comment or report problem with topic
