No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
TheExternalId of objects in MDriven | 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 | The class Id must be present in order for the framework to know in which class your object resides. | ||
The class | 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 | 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 | 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 | 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 | 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. | ||
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 | 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 use of this GuidProperty. This is how: <classid>!GP!<guid> - ie GP is short for Guid Property. | ||
This enables us to express the | 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. | 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 | What is good about this is that the exposed information is now not tied to anything that changes easily for a specific system instance. This way, we can trust that links are consistent over time. | ||
See | See also: [[The_VMClassId_Explained]] | ||
See also [[MVC GetImage]] | See also: [[MVC GetImage]] | ||
See also [[OCLOperators_objectfromExternalId]] | See also: [[OCLOperators_objectfromExternalId]] | ||
[[Category:OCLOperators]] | [[Category:OCLOperators]] |
Revision as of 08:35, 6 March 2023
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.
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 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.
What is good about this is that the exposed information is now not tied to anything that changes 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