Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

General

All builders that derive from MetadataBuilderBase will have the Builder property available to them. That property can be used to add, remove or retrieve metadata from the current model. The type behind the property is ModelBuilder - so the builder is already scoped to the current model.

Add

Class

To add an additional class simply use:

Builder.Add.Class(nameof(Elements.Office));

This will return an instace of ClassBuilder that can be used to furhter configure the created class.

A class with some additional configurations:

Builder.Add.Class(nameof(Elements.Office))
        .Caption(SwissGerman, "Büro")
        .PluralCaption(SwissGerman, "Büros")
        .NoCodeGeneration()
        .Sort("Name", SortDirection.Descending);

There's a fallback available in case the developer needs access to the underlying IMetaClass:

Builder.Add.Class(nameof(Elements.Office))
        .Configure(cls =>
        {
          // Do something with the IMetaClass
        });

Property

To add an additional property simply use:

Builder.Add.Property(Elements.Office, "Name", MetaType.Text);

This will return an instace of PropertyBuilder that can be used to furhter configure the created property.

A property with some additional configurations:

Builder.Add.Property(Elements.Office, "ShowPeople", MetaType.Boolean)
  .Caption(SwissGerman, "Personen anzeigen")
  .Required()
  .Transient()
  .DefaultExpression("true");

There's a fallback available in case the developer needs access to the underlying IMetaProperty:

Builder.Add.Property(Elements.Office, "ShowPeople", MetaType.Boolean)
        .Configure(prop =>
        {
          // Do something with the IMetaProperty
        });

Relation

To add a relation simply use:

Builder.Add.Relation(Elements.Company, AssociationType.ZeroOrOneToMany, Elements.Office, MetaPathRule.Cascade)

This will return an instance of RelationBuilder that can be used to further configure the created relation.

A relation with some additional configurations:

Builder.Add.Relation(Elements.Company, AssociationType.ZeroOrOneToMany, Elements.Office, MetaPathRule.Cascade)
  .Caption(SwissGerman, "Büros")
  .InverseCaption(SwissGerman, "Firma")
  .Control(nameof(ControlType.GridEditor))
  .InverseControl(nameof(ControlType.SearchEdit))
  .InverseLayout(LayoutType.Detail, "CompactLayout")
  .Rename("Offices");

There's a fallback available in case the developer needs access to the underlying generated elements:

Builder.Add.Relation(Elements.Company, AssociationType.ZeroOrOneToMany, Elements.Office, MetaPathRule.Cascade)
  .Configure(tuple =>
  {
    // tuple.relation;
    // tuple.inverseRelation;
    // tuple.foreignKey;
    // tuple.path;
    // tuple.index;
  });

Remove

The Builder exposes a property Remove that can be used to either remove a class or property from the model.

Builder.Remove.Class("Office");
Builder.Remove.Property("Office", "Name");

Get

The Builder exposes a property Get that can be used to either retrieve a class or property from the model.

Builder.Get.Class("Office");
Builder.Get.Property("Office", "Name");

  • No labels