Creating, Updating, and Deleting MBO Records

Perform create, update, and delete operations on the MBO instances that you have created.

You can call the Create, Update, and Delete methods for MBO instances.

Note: For MBOs with custom create or update operations with parameters, you should use the custom operations, rather than the default and operations. See MBOs with Complex Types.
  1. Suppose you have an MBO named Customer. To create an instance within the database, invoke its Create method, which causes the object to enter a pending state. Then call the MBO instance's SubmitPending method. Finally, synchronize with the generated database:
    Customer newcustomer = new Customer();
    //Set the required fields for the customer
    // …
    
    newcustomer.Create();
    newcustomer.SubmitPending();
    SUP101DB.Synchronize();
  2. To update an existing MBO instance, retrieve the object instance through a query, update its attributes, and invoke its Update method, which causes the object to enter a pending state. Then call the MBO instance's SubmitPending method. Finally, synchronize with the generated database:
    Customer customer = Customer.FindByPrimary(myCustomerId) //find by primary key
    customer.City = "Dublin"; //update any field to a new value
    customer.Update();
    customer.SubmitPending();
    SUP101DB.Synchronize(); 
    
  3. To delete an existing MBO instance, retrieve the object instance through a query and invoke its Delete method, which causes the object to enter a pending state. Then call the MBO instance's SubmitPending method. Finally, synchronize with the generated database:
    Customer newcustomer = new Customer();
    Customer customer = Customer.FindByPrimary(myCustomerId) //find by primary key
    customer.Delete();
    customer.SubmitPending();
    SUP101DB.Synchronize();
Related reference
Operations APIs