Skip to main content

The Link class represents a link to other content such as an Entry, Asset or Image. The Link class can target a specific language variation of the linked content. If a language is not specified when creating a link, then the project default is used. The DataFormat property does not need to be specified when a Link is created as it will be determined and set by the API service.

Constructors

Syntax

C#
public Link(Guid id, string language = null)
{
}

Parameters

id

Type: Guid
The id of the entry or asset.

language

Type: string [LanguageCode]
[Optional] The language variation of the asset to target.


Syntax

C#
public Link(string id, string language = null)
{
}

Parameters

id

Type: string
The id of the image asset.

language

Type: string [LanguageCode]
[Optional] The language variation of the asset to target.

Properties

Name Type Description
Id Guid The id of the entry or asset.
Language string [] The language of the link instance.
DataFormat string An indicator of the link type - entry or asset.

Examples

C#
// Get the field value as a Location instance.
Link actor = movieEntry.Get<Link>("leadActor");

// Get the field value as a dynamic (ExpandoObject) instance.
dynamic actor = movieEntry.Get("leadActor");
C#
// Get the field value as a Link list.
List<Link> actors = movieEntry.Get<List<Link>>("actors");

// Alternatively get the field value as a Link array.
Link[] actors = movieEntry.Get<Link[]>("actors");
C#
// Create a Link object targeting the default project language.
Link actor = new Link("27293124-999a-4895-afec-f060dca33508");

// Set the link value.
movieEntry.Set("leadActor", actor);

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request