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 MetaClassManager class represents the entry point to the meta model. It is available from the DataContext.MetaModel property. The MetaModel is used for getting meta classes, registered meta types and relationships, as well as for creating and deleting meta classes. Also, MetaClassManager includes the static events MetaClassCreating, MetaClassCreated, MetaClassDeleting, MetaClassDeleted, MetaFieldCreating, MetaFieldCreated, MetaFieldDeleting, MetaFieldDeleted. You can subscribe to these events in order to get information about external meta model modifications.
The Business Meta Model can enter these modes:
A runtime mode is a default state allowing for work with objects, and you can create, load, updated and delete entity objects in this mode.
Upon instantiating a MetaClassManagerEditScope by the calling MetaClassManager.BeginEdit statement, the meta model manager determines which mode to participate in. Once determined, the scope always participates in that edit scope. You can obtain a reference to the ambient edit scope by calling the Current property of the MetaClassManagerEditScope class.
If no exception occurs within the transaction scope (that is, between the initialization of the MetaClassManagerEditScope object and the calling of its Dispose method), then the transaction in which the scope participates is allowed to proceed. If an exception does occur within the edit scope, the transaction in which it participates will be rolled back.
When your application completes all work needed in a transaction, you should call the SaveChanges method only once to inform that meta model manager that it is acceptable to commit the transaction. Failing to call this method aborts the transaction. Afterwards, the SaveChanges meta model modifications are available to all users. A call to the Dispose method marks the end of the edit scope. Exceptions that occur after calling this method may not affect the transaction.
Example: The Open meta model edit scope
// Open Meta model edit scope
using (MetaClassManagerEditScope scope =
DataContext.Current.MetaModel.BeginEdit())
{
// Modify meta model here
// Save Changes
scope.SaveChanges();
}
Last updated: Oct 21, 2014