Skip to content

Business Object Model Producer

Simon Mourier edited this page Feb 19, 2020 · 1 revision

This topic is about the Business Object Model producer, it describes how to configure the producer to generate the business objects layer above the persistence layer. 

You can use this producer to generate .NET class for the entities declared in design model.

It also ships with one sub-producers out-of-the-box: The Object Model Cache Producer to add cache specific code to the methods of the generated .NET class.

For each entity, the BOM producer generates two business objects: one object for the entity and one object for the entity set.

You can notice that the producer generates two classes for, say, the Customer entity:

  • the Customer class with the properties, say Id, FirstName, LastName

  • the CustomerCollection class with the properties Count and the this[int index] indexer.

Business Object Model Producer - Picture 278

// Class Customer
public class Customer
{
    // Fields
    private string _firstName;
    private int _id;
    private string _lastName;
 
    // Methods
    public static bool Delete(Customer customer);
    public static bool Insert(Customer customer);
    public static Customer Load(int id);
    public static bool Save(Customer customer);
 
    // Properties
    public string FirstName { get; set; }
    public int Id { get; set; }
    public string LastName { get; set; }
}
 
// Class CustomerCollection
public class CustomerCollection
{
    // Fields
    private List<Customer> _baseList;
    private Dictionary<int, Customer> _baseTable;
 
    // Methods
    public static bool Delete(Customer customer);
    public static bool Insert(Customer customer);
    public static CustomerCollection LoadAll();
    public static bool Save(Customer customer);
 
    // Properties
    public virtual int Count { get; }
    public Customer this[int index] { get; set; }
}

You can also notice that the two classes generated by default have the same signature for the Insert, Save and Delete persistence method. Fortunately, for the Load method, the signature is different: The Customer class has a Load method to load one entity and the CustomerCollection class has a LoadAll method to load all the entities.

Clone this wiki locally