Read / Access Metadata - (advanced ⚠)
There are two ways to read / access Metadata
- On most 2sxc Data-objects there is a property called
Metadata
which contains everything you need - To get Metadata for other Data there is a simple API to retrieve it
Get Metadata on 2sxc Data Objects #todoc
Many standard 2sxc object have a property Metadata to quickly access all Metadata of that object. You can find the docs in IMetadataOf. This applies to all kinds of objects like
- Entities
- Content-Types
- Apps
- ADAM files and folders
Get Metadata for ADAM Files and Folders #todoc
All ADAM Assets also have the .Metadata
property to read the metadata as well as a .HasMetadata
to quickly see if Metadata has been set.
Edge cases of the .Metadata
Property
Since .Metadata
is often used in dynamic code it's optimized to just work. This means it has the following effects
- It will always return a valid object, even if there is no metadata attached
- If no metadata exists, the
EntityId
will always equal zero0
- If it has one or more metadata items attached, the
EntityId
will be that of the first Metadata-Entities found
#todoc - this should probably be moved to the C# API infos
Get Metadata for Data outside of 2sxc #todoc
To read Metadata for non-2sxc objects you must request it from the App.Data.Metadata or from the AppState.MetadataSource object. Both are a a IMetadataSource. Use commands like GetMetadata<T>(...)
to access the metadata you need.
Read also #todoc
Demo App and further links #todoc
History
- Introduced in 2sxc v2