The ExternalId explained
No edit summary
(Automatically adding template at the end of the page.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
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.
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 what class your object resides.
The Class Id must be present in order for the Framework to know in which class your object resides.


The class id will however change when you update the model.
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 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.
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 for you to send in class name: Thing!10
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 make them more exposed than what they where designed for.
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 a object identity and a attribute with a blob, like this: [http://localhost:5052/Turnkey/GetImage?img=Thing!GP!ad833fd8383c4389a88f3349166e7a74-SomeImage http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage]
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=Thing!GP!ad833fd8383c4389a88f3349166e7a74-SomeImage http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage]


You can now write : [http://localhost:5052/Turnkey/GetImage?img=Thing!GP!ad833fd8383c4389a88f3349166e7a74-SomeImage http://localhost:5052/Turnkey/GetImage?img=Thing!10-SomeImage] instead to make sure that the link survives in changed models.
You can now write: [http://localhost:5052/Turnkey/GetImage?img=Thing!GP!ad833fd8383c4389a88f3349166e7a74-SomeImage 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|Information Hygiene]].
It is also best practice to have a Guid attribute on all of your classes as described in [[Information hygiene|Information Hygiene]].


If you have so an even better way would be to use the guid in exposed links possibly saved by others.
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 use of this GuidProperty. This is how: <classid>!GP!<guid>  - ie GP is short for Guid Property.
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 shortformat (Guid.ToString('N') removes the -) like this:
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
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.
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: [[The_VMClassId_Explained]]


See also [[MVC GetImage]]
See also: [[MVC GetImage]]
 
See also: [[OCLOperators_objectfromExternalId]]
[[Category:OCLOperators]]
{{Edited|July|12|2024}}

Latest revision as of 15:48, 10 February 2024

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 98 days ago on 02/10/2024. What links here