Working with Meta Class from Commerce v10

  • Updated

In Commerce v10, Metadata Plus is introduced. This article demonstrates performing CRUD actions with the new MetaClass class (in the Mediachase.MetaDataPlus.Configurator assembly) in Catalog and Order systems. 

var metaDataContext = CatalogContext.MetaDataContext;
var metaClassName = "Something";
var tableName = String.Format("{0}{1}{2}", parentMetaClass.Name, "Ex_", metaClassName);
var parentMetaClass = MetaClass.Load(metaDataContext, "CatalogEntry");

MetaClass.Create(metaDataContext, metaClassName, "friendly name",tableName, parentMetaClass.Id, false, "description");

MetaClass.Load(CatalogContext.MetaDataContext, "metaClassName")

//Update: just set the meta class properties.
metaClass.Name += "-updated";

MetaClass.Delete(CatalogContext.MetaDataContext, id);