Up Model
DevForce 2010 Resource Center » DevForce development » Model » Examine model metadata

Examine model metadata

Last modified on August 15, 2012 17:22

Examine entity model metadata programmatically by interrogating the EntityMetadata object held in the EntityMetadataStore singleton.

The EntityMetadataStore

DevForce maintains a thread-safe repository of metadata for all types in a domain model. Applications can query the store using the GetEntityMetadata() method for a type:

EntityMetadata employeeEntityMetaData =
Dim employeeEntityMetaData As EntityMetadata = _
  EntityMetadataStore.Instance.GetEntityMetadata( _

You can also access the EntityMetadata for any entity instance using its EntityAspect:

var cust = _em1.Customers.First();
var metadata = cust.EntityAspect.EntityMetadata;
Dim cust = _em1.Customers.First()
Dim metadata = cust.EntityAspect.EntityMetadata

The EntityMetadata provides the following members:


The table below provides an explanation for a few key members:

PropertyCanQueryByEntityKeyGets whether primary key queries are allowed.
PropertyComplexTypePropertiesReturns a collection of DataEntityProperties that describe complex object properties for entities of this type.
PropertyConcurrencyPropertiesReturns a collection of DataEntityProperties that are concurrency properties for entities of this type.
MethodCreateEntity()Creates a new entity of the type described by this metadata item.
PropertyDataPropertiesReturns a collection of DataEntityProperties for entities of this type.
PropertyDataSourceKeyNameGets the name of the Data Source Key associated with this type.
PropertyDefaultValueFunctionStatic - Use to override how DevForce sets the default value for a data entity property.
PropertyEntityPropertiesReturns a collection of EntityProperties that belong to entities of this type.
PropertyEntityTypeGets the type of the entity.
PropertyForeignKeyPropertiesReturns a collection of ForegnKey DataEntityProperties
PropertyHasStoreGeneratedIdReturns whether this entity type has a store generated id.
PropertyIsComplexObjectTypeReturns whether this metadata describes a ComplexObject.
PropertyKeyPropertiesReturns a collection of DataEntityProperties that are keys for entities of this type.
PropertyNavigationPropertiesReturns a collection of NavigationEntityProperties for entities of this type.

Property Metadata

When DevForce generates the code for your domain model it includes a nested class called PropertyMetadata within each generated Entity. Within PropertyMetadata are static fields for all the EntityProperty definitions within the entity. You’ll see a DataEntityProperty for every non-navigation property, and either a NavigationScalarEntityProperty  or NavigationListEntityProperty  for all navigation properties.

You can easily access these properties at any time via the static field definitions:

var dataProp = Customer.PropertyMetadata.Id;
var navListProp = Customer.PropertyMetadata.OrderSummaries;
var navScalarProp = OrderSummary.PropertyMetadata.Customer;
Dim dataProp = Customer.PropertyMetadata.Id
Dim navListProp = Customer.PropertyMetadata.OrderSummaries
Dim navScalarProp = OrderSummary.PropertyMetadata.Customer

Also generated into each Entity class is a nested class called EntityPropertyNames. This class contains string constants for all the property names within the entity.

public partial class Employee : IbEm.Entity {
 public new partial class EntityPropertyNames :
    IbEm.Entity.EntityPropertyNames {
   public const String Id = "Id";
   public const String LastName = "LastName";
   public const String FirstName = "FirstName";
Partial Public Class Employee
 Inherits IbEm.Entity
 Partial Public Shadows Class EntityPropertyNames
   Inherits IbEm.Entity.EntityPropertyNames
   Public Const Id As String = "Id"
   Public Const LastName As String = "LastName"
   Public Const FirstName As String = "FirstName"
 End Class
End Class
Tags: Model Metadata
Created by DevForce on September 23, 2010 13:23

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2015 IdeaBlade