MDrivenWiki
Log in

The ExternalId explained

From MDrivenWiki

TheExternalId of objects in MDriven take 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 what class your object resides.

The class id will however change 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 and 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 for you to send in class name: Thing!10

This is good when exposing the externalids in links etc and thus possibly make them more exposed than what they where designed for.

For example in MVC we have a controller GetImage that expects a object identity and a 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.

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

If you have 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 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 shortformat (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.

What is good about this is that the exposed information is now not tied to anything that change easily for a specific system instance. This way we can trust that links are consistent over time.

See Also The_VMClassId_Explained

See also MVC GetImage

See also OCLOperators_objectfromExternalId