Metadata
Created by Richard Saunders, last modified by Simon Horan on 23 Jan 2020
The Metadata type is an object container for metadata that is associated with an Entry. The values contained can be any type which can be accessed as either a dynamic object or cast to a specific type.
Properties
Name | Type | Description |
---|---|---|
Keys | ICollection<string> | A collection of the keys available |
Methods
Get
Gets a value by the specified key and returns a dynamic object instance.
Syntax
public dynamic Get(string key)
{
}
Parameters
key
Type: string
The key for the data item
Remarks
Returns null if the key does not exist or if the value is null.
Example
@using Zengenti.Contensis.Delivery;
@{
// Create a client
var client = ContensisClient.Create();
// Retrieve an entry
var movie = client.Entries.Get("1d1d3724-3f53-4589-8ea3-b16a1f3921f5");
// Check that a metadata item exists and access it
if (movie.Metadata.Keys.Contains("originalId"))
{
var originalId = movie.Metadata.Get("originalId");
// Use the value
}
}
Get<T>
Gets a value by the specified key and returns the object instance as T.
Syntax
public T Get<T>(string key)
{
}
Parameters
T
The type to attempt to cast the field data to.
key
Type: string
The key for the data item
Remarks
Returns null if the key does not exist or if the value is null.
Example
@using Zengenti.Contensis.Delivery;
@{
// Create a client
var client = ContensisClient.Create();
// Retrieve an entry
var movie = client.Entries.Get("1d1d3724-3f53-4589-8ea3-b16a1f3921f5");
// Check that a metadata item exists and access it
if (movie.Metadata.Keys.Contains("originalId"))
{
var originalId = movie.Metadata.Get<string>("originalId");
// Use the value
}
}