Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
The MetaType class represents the field type declarations string, HTML text, number, enums, file, and image. MetaType includes common types and you can extend it with UI-friendly types. For example, instead of using one type of string, Business Meta-Model has Short String, Long String, HTML, Email, Phone and number. You can create a new MetaType based on system type or create a custom one.
Business Foundation (BF) lets you use a number of different meta types for your .NET applications. You can use the included meta-types, or you can implement your own custom meta-type.
Call the RegisteredTypes method of MetaClassManager class to get all registered meta-types. The following table shows ready-to-use BF meta-types.
Name | System Type | Represents |
---|---|---|
Guid |
Guid |
A globally unique identifier (GUID). |
DateTime |
DateTime |
An instant in time, typically expressed as a date and time of day. |
Date |
DateTime |
An instant in date. |
Integer |
Integer |
A 32-bit signed integer. |
Float |
Double |
A double-precision floating-point number. |
Currency |
Currency |
A currency number . |
CheckboxBoolean |
Boolean |
A Boolean value with checkbox. |
DropDownBoolean |
Boolean |
A Boolean value with drop-down. |
Text |
String |
Text of fixed length. Maximum length is 4096 chars. |
|
String |
An e-mail string. |
Url |
String |
A URL string. |
LongText |
String |
A long text. |
Html |
String |
An HTML string. |
File |
File |
A file (name, length, content type, stream). |
Image |
File |
An image file. |
IntegerPercent |
Integer |
A 32-bit signed integer percent. |
FloatPercent |
Double |
A double-precision floating-point percent. |
Duration |
Integer |
A 32-bit signed integer duration value. |
You can create a new meta-type based on system type. You can find a complete list of system types in the McDataType enumerators.
To create a meta-type, such as Geolocation based on the String system type, open the edit scope and add a new MetaFieldType object to the MetaClassManager.RegisteredTypes collection.
// Open Meta model edit scope
using (MetaClassManagerEditScope scope =
DataContext.Current.MetaModel.BeginEdit())
{
// Add a new meta type
MetaFieldType geoLocation = new MetaFieldType("Geolocation",
"Geolocation", McDataType.String);
DataContext.Current.MetaModel.RegisteredTypes.Add(geoLocation);
// Save Changes
scope.SaveChanges();
}
Or, add a new record to the mcmd_MetaFieldType table and restart the application.
*INSERT INTO mcmd_MetaFieldType ([Name], [FriendlyName], [McDataType]) VALUES ('Geolocation', 'Geolocation ', 6
After registration, you can add a geolocation field to the meta-class. Using the meta-type name, you can load a new geolocation view and edit the UI control.
When implementing a custom meta-type, you need to create the Meta-field installer and Meta-field property binder. When you create a meta-field, BF calls the meta-field installer to process meta-field into SQL columns. When you load an entity object, BF calls the meta-object property binder to convert values from an SQL column to a meta-field value.
To create a custom Meta-field installer, you create a class that implements the IMetaFieldInstaller interface, and implement the following methods.
Name | Description |
---|---|
AssignDataSource |
Create a new columns in the SQL database from meta-field |
AssignValidators |
Assign default validators |
UpdateDataSource |
Update SQL columns from updated meta-field |
UpdateValidators |
Update validators |
RemoveDataSource |
Remove columns from SQL database |
RemoveValidators |
Remove validators |
To create a custom Meta-object property binder, you create a class that implements the IMetaObjectPropertyBinder interface, and implement the following methods.
Name | Description |
---|---|
PreLoad |
Load value from SQL row and save to meta field property. |
PostLoad |
Fill properties by other. |
PreSave |
Save value to SQL row. |
PostSave |
Fill properties by other. |
Delete |
Clean up if meta field is removing. |
InitTableConfig |
Initialize additional SQL relations. |
You should register the custom meta-field installer and meta-object property binder in the mediachase.businessFoundation.data/metaObject/types section of the application config file.
<mediachase.businessFoundation.data>
<metaObject>
<types>
<add name="CustomType" installer="" binder="" />*
</types>
Last updated: Oct 12, 2015