Working with Metadata

Most of the time when you’re working with LightSpeed, you’re working with specific entities and using those entity classes.  Sometimes, however, a utility method needs to be able to work with any kind of entity, rather than being specialised to a particular entity type.

An example might be generic copy or compare methods, which could be useful in resolving optimistic concurrency conflicts.  A generic compare method could compare the attribute values of one entity to those of another entity of the same type, and a generic copy method could that copy all or selected values.  Such methods need to know what attributes an entity has, but it would be tedious to re‑implement them for each entity class (and maintain them as the class evolved).

To help you implement such methods, LightSpeed provides a metadata API which you can use to enumerate, examine and update entity attributes.

The LightSpeed Metamodel

Getting Class Information

Getting and Setting Fields through Metadata