Classes in this topic are available in the Mediachase.BusinessFoundation.Data.Meta and Mediachase.BusinessFoundation.Data.Meta.Management namespaces. For information about working with data through business objects, see Working with entity objects.
MetaType represents these field type declarations: string, HTML text, number, enums, file, image, and so on. MetaType includes common types. You can extend MetaType to include UI-friendly types. For example, instead of using one type of string, the Business Meta-Model has Short String, Long String, HTML, email, and phone number. You can easily create a new MetaType based on a system type or a customized type.
MetaEnum represents single or multi-select enumerations. When a new MetaEnum is created, it registers a new meta-type.
MetaClass represents a class containing a collection of meta-fields. You can use a meta-class to create an entity object. You can modify meta-class fields (add, remove) at runtime.
BF supports 1-N, N-N and aggregation references between two meta-classes.
The following modules represent customized extensions that you can install in the system and activate in the meta-class.
- Change Tracking. Adds a new field to meta class and registers user and modification date/time.
- History. Saves meta object modifications to the history meta class.
- Localization. Allows localized field values.
The Business Meta Model uses a SQL Server database for data storage. To manually prepare the database, run the SqlTables.sql, SqlSp.sql, and SqlInitialData.sql scripts, which create the infrastructure for the meta-model data storage.
A database can have only one Business Meta-Model. A DataContext object represents a unique entry point to the Business Meta-Model. When you create an instance of DataContext, Business Meta-Model is loaded, and all properties are set to their initial values. Then, you should initialize the DataContext.Current static property to declare DataContext in the current thread. The DataContext is available in the current thread from the DataContext.DataContext static property.
If the DataContext goes out of scope, it is not closed. So, you must explicitly close the context by calling Dispose.
The DataContext.Current property is a thread, and you should initialize it in all threads. By changing the DataContext.Current property, you can connect to different meta-models, but only one connection is active.
Example: Initializing DataContext in the current thread:
// Step 0. Connection String string connectionString = "Data Source=(local);Initial Catalog=TestDatabase;User ID=sa;Password=;"; // Step 1. Initiaze Sql Metamodel DataContext.Current = new DataContext(connectionString);
In an ASP.NET application, initialize DataContext in the Global. Application_BeginRequest method.
Updated 4 months ago