The ExternalId explained

TheExternalId of objects in MDriven takes on the form of classindex!objectid - for example, 9!10 refers to an object stored with primary key 10 in a model where the 9:th class gives the table name.

The Class Id must be present in order for the Framework to know in which class your object resides.

The Class Id will change, however, when you update the model.

Class Id 0 always refers to the topological highest class in your model - the root of everything; this is often abstract. The Framework can try to look up objects this way, but as you can imagine, it would need to search all tables in order to find the relevant class.

To make the ExternalId a bit more resilient to change, we now allow you to send in the class name: Thing!10

This is good when exposing the ExternalIds in links, etc, and thus, possibly makes them more exposed than what they were designed for.

For example, in MVC, we have a controller, GetImage, that expects an object identity and an attribute with a Blob, like this: http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage

You can now write: http://localhost:5052/Turnkey/GetImage?img=Thing!10-SomeImage instead to make sure that the link survives in changed models.

Guid

It is also best practice to have a Guid attribute on all of your classes as described in Information Hygiene.

If you have done so, an even better way would be to use the Guid in exposed links possibly saved by others.

We have now extended the interpretation of sent-in ExternalId's to allow for the use of this GuidProperty. This is how: <classid>!GP!<guid> - ie GP is short for Guid Property.

This enables us to express the Guid in short format (Guid.ToString('N') removes the -) like this:

http://localhost:5052/Turnkey/GetImage?img=Thing!GP!ad833fd8383c4389a88f3349166e7a74-SomeImage where "SomeImage" is the attribute name of the image.

This is beneficial because the exposed information is now not tied to anything that changes easily for a specific system instance. This way, we can trust that the links are consistent over time.

See also: The_VMClassId_Explained

See also: MVC GetImage

See also: OCLOperators_objectfromExternalId

This page was edited 157 days ago on 06/17/2024. What links here