The Entity Framework Generator generates the following framework signature based on the T4 template:
public partial class Material : VBEntityObject, IInsertInfo, IUpdateInfo, IDeleteInfo
gip.core.datamodel.VBEntityObject is the base class for all entity classes so that the additional iPlus features can be used. It specifies a number of virtual methods and common functionalities that can be overwritten or reused in the derivations. The interfaces IInsertInfo, IUpdateInfo and IDeleteInfo are added automatically because the T4 template in the edmx model examines the entities according to the fields "InsertDate, InsertName, UpdateName ...".
Then program the rest of the program code in another C# file where you extend the partial class (see F in the first picture above). The partial class should be expanded with the following color-coded code areas:
Partial class definition (A)
Add a partial class definition.
Classes and property description using attribute classes
(A) & (B): Add an ACClassInfo attribute class (A) with Global.ACKinds .TACDBA (B). This is how you announce this entity class to the iPlus framework. It then appears in the development environment below the associated database context class in the iPlus application tree (this also applies to the model-first approach).
(C): Since the properties of the entity class are declared in the other partial class created by the T4 template generator, the ACClassPropertyInfo attribute cannot be declared there, because it will be removed by running again the T4 template. Instead, use the ACPropertyEntity attribute class (C). For each database field or property of the entity class, you declare an ACPropertyEntity line and enter the name of the property in the first parameter. The remaining construction parameters are the same as for the ACClassPropertyInfo class. For string properties (SQL type varchar), enter the maximum length of the string with "MaxLength".
However, if you use the model-first approach (by foregoing the iPlus features), you can use the ACClassPropertyInfo attribute as normal for your properties.
(D): Optional: Define a template for the storable queries (ACQueryDefinition). A storable query should always be defined if the table (or the entity class) in business objects is the main table which is filtered and navigated to.
(F): Optional: Define an ACSerializable attribute so that a smart pointer to an object of this entity class can be used in a network capable property.
Implementation of VBEntityObject
VBEntityObject has several virtual methods with a standard implementation for adding, deleting and changing objects. Overwrite this if you want to add your individual logic and call the basic implementation at the end of the method.
(A): To add new objects, declare a static method with the following signature:
public static MyEntityClassT NewACObject(MyDbContextClass dbApp, IACObject parentACObject, string secondaryKey)
In this method, you then create a new instance of the entity class (MyEntityClassT) and set the primary key with a new GUID (B) .
(C): Then call the extension method DefaultValuesACObject() so that all properties of your entity class or generally of an IACObject are initialized with the default values that have been configured in the development environment.
(D): If your table has a secondary key (a database field with a legible key), you can use the number generator to generate it and pass it to the "secondaryKey" parameter. The number ranges of the number generator can be configured with the business object gip.bso.iplus.BSONoConfiguration in advance.
(E): Call the SetInsertAndUpdateInfo() method to have the user name and the current time entered in the "Insert" fields.
Attention: The object is not yet in change tracking! Either add the newly generated object immediately to the DB context or do it outside of the NewACObject() method.