How to Make M-Class

Model Folder contain all the M-Classes. M-class inherit the X-class so that it can access its properties like getter and setter.  

Naming conventions for M-Class: 

If table name contains prefix with up to 2 characters then ignore prefix and all underscores ( _ ) and append M as prefix to rest of the name.For Example table name is AD_WF_Node then name of M-Class will be MWFNode. If table name is AD_Table then M-Class will be MTable. 

 

If Table name contains prefix with more than 2 characters then ignore only underscore ( _ ) and append M as prefix to rest of the name. Recommended is to use minimum of three characters in prefix. 

 

For Example table name is WXYZ_WF_Node then name of M-Class will be MWXYZWFNode. 

If table name is VAT_Employee then name of M-Class will be MVATEmployee. 

There are four methods on which developer can work.These are: 

 

Before Save: 

 

 If user wants to add some business logic before saving the data, then use BeforeSave() method. 

 

Before Delete: 

 

If user wants to add some business logic before deleting the data, then use BeforeDelete() method. 

 

After Save: 

 

 If user wants to add some business logic after saving the data, then use AfterSave() method. 

 

After Delete: 

 

 If user wants to add some business logic after deleting the data, then use AfterDelete() method. 

 

It has two default parameterize constructors as show in below pic. 

 

  • public MClass (Ctx ctx, int Record_ID, Trx trxName) 

    This constructoris used to get a particular record based on Record_ID passed to it and also used to create new record in that table. 

    If you know a particular Record_ID then this constructor will return that record. 

    If you pass 0 as Record_ID then it will create a new Record. That record will be saved into database when you call save function with instance of that class. 
 

  •    public MClass (Ctx ctx, DataRow rs, Trx trxName) 

    When you have Record in your dataset or you have data row for data and you want to initialize MClass for that  record then pass that datarow to this constructor. In this way you will reduce time as this will not go to database again to get that data for class instance initialization. 

 

 The above example is of Model Folder structure.  

If you want to explore more about MClasses and XClasses then explore product ModelLibrary project 

ModelLibrary\Model” Folder 

For Add MClass in Module Projects then add class in ViennaAdvantageSvc/Molder Folder