Try our conversational search powered by Generative AI!

Loading...
Applies to versions: 10 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

MetaType class

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

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 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.

Creating 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.

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.

Creating 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.

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

 

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

"Commerce":{      
"MetaObjectTypeOptions": {
        "Types": [
          {
            "Name": "CustomType",
            "Installer": "",
            "Binder": ""
          }
        ]
      }
}
Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading