EntityRegister

EntityRegister[estore]

registers the entities in the entity store estore so that they can be accessed directly using Entity.

Details

  • The list of entity stores whose contents have been registered is given by EntityStores[].
  • Entity["type","name"] is interpreted as an entity from the first entity store in EntityStores[ ] that contains "type".
  • Entity types that appear in EntityStores[] are considered before built-in entity types.
  • During assignments Entity["type","name"][property]=value, data is stored in the first EntityStore in EntityStores[] that contains "type". If no EntityStore in EntityStores[] contains "type", a new EntityStore is registered.
  • EntityRegister[] returns the list of entity types that it has registered.

Examples

open allclose all

Basic Examples  (1)

Register an entity store that contains data about fruit:

List all "fruit" entities:

Look up the color of a banana:

Add data of an additional fruit:

Find the entity store that is accessed when retrieving data of the "fruit" entity type:

List all registered entity stores:

Unregister the "fruit" entity store:

Scope  (2)

During assignments, separate entity stores are created for each new entity type:

To direct data into the same entity store, register one store containing both types before making assignments:

Referencing any of the types is enough to unregister the whole entity store:

Register an entity store that contains two types:

Register another store that shadows the type "t2":

Now the entity Entity["t2","f"] refers to the entity in the newly registered store:

Unregistering type "t2" will restore the previous result:

Unregister type "t1":

Possible Issues  (1)

When dealing with external databases, one might encounter a database where the primary key was not set for some tables:

When this happens, EntityStore will emit a message. This means that some functionality involving single entities will be disabled:

But EntityValue will generally keep working:

The only way around this problem is to set the primary key constraint in the external database.

Introduced in 2018
 (11.3)