HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

MetaType class

Describes the MetaType class in Optimizely Customized Commerce 13, which 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 implement a custom meta-type.

Default meta-types

Call the RegisteredTypes method of MetaClassManager class to get all registered meta-types. The following table shows ready-to-use BF meta-types.

Ready-to-use BF meta-types

NameSystem TypeRepresents
GuidGuidA globally unique identifier (GUID).
DateTimeDateTimeAn instant in time, typically expressed as a date and time of day.
DateDateTimeAn instant in date.
IntegerIntegerA 32-bit signed integer.
FloatDoubleA double-precision floating-point number.
CurrencyCurrencyA currency number.
CheckboxBooleanBooleanA Boolean value with check box.
DropDownBooleanBooleanA Boolean value with drop-down.
TextStringText of fixed length. Maximum length is 4096 chars.
EMailStringAn e-mail string.
UrlStringA URL string.
LongTextStringA long text.
HtmlStringAn HTML string.
FileFileA file (name, length, content type, stream).
ImageFileAn image file.
IntegerPercentIntegerA 32-bit signed integer percent.
FloatPercentDoubleA double-precision floating-point percent.
DurationIntegerA 32-bit signed integer duration value.

Create a meta type based on system type

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.

Code sample

// 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);
        // Save Changes

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.

Create a custom meta type

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.

IMetaFieldInstaller interface methods

AssignDataSourceCreate a new columns in the SQL database from meta-field
AssignValidatorsAssign default validators
UpdateDataSourceUpdate SQL columns from updated meta-field
UpdateValidatorsUpdate validators
RemoveDataSourceRemove columns from SQL database
RemoveValidatorsRemove validators

To create a custom Meta-object property binder, create a class that implements the IMetaObjectPropertyBinder interface, and implement the following methods.

IMetaObjectPropertyBinder interface methods

PreLoadLoad value from SQL row and save to meta field property.
PostLoadFill properties by other.
PreSaveSave value to SQL row.
PostSaveFill properties by other.
DeleteClean up if meta field is removing.
InitTableConfigInitialize additional SQL relations.

Customized Commerce version 14
You should register the custom meta-field installer and meta-object property binder in the appsettings.json Commerce section.

    "MetaObjectTypeOptions": {
            "Types": [
                "Name": "CustomType",
                "Installer": "",
                "Binder": ""

Customized Commerce version 10-13

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.

        <add name="CustomType" installer="" binder="" />*