---
title: "Interface IRelation"
slug: "sdk--stylelabs.m.sdk.contracts.base.irelation"
abstract: ""
---
# Interface IRelation

Base interface for relations.

## Inherited Members

[IMember.Name](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.imember.html)

[IMember.DefinitionType](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.imember.html)

[IDirtyTracking.IsTracking](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.dirtytracking.idirtytracking.html)

[IDirtyTracking.IsDirty](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.dirtytracking.idirtytracking.html)

[IDirtyTracking.StartTracking()](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.dirtytracking.idirtytracking.html)

[IDirtyTracking.MarkClean()](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.dirtytracking.idirtytracking.html)

## Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ContractsBase

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public interface IRelation : IMember, IDirtyTracking
```

## Properties

### Properties

Gets the properties of the linked entity.

#### Declaration

```csharp
IDictionary<long, IDictionary<string, JToken>> Properties { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| IDictionary<, >longIDictionary<, >stringJToken |  |

### [Role](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.resources.base.role.html)

Gets the role of this instance in the relation.

#### Declaration

```csharp
RelationRole Role { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| [RelationRole](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadoptions.relationrole.html) |  |

## Methods

### Clear()

Clears the value(s) of the relation.

#### Declaration

```csharp
void Clear()
```

### GetIds()

This utility method allows getting the value of any type of relation.

In case of an [IToManyRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itomanyrelation.html) the result will contain all ids on the relation.

In case of an [IToOneRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itoonerelation.html) the list can contain 1 id (maximum) if an id was set on the relation. If no id was set on the relation, an empty list is returned.

#### Declaration

```csharp
IList<long> GetIds()
```

#### Returns

| Type | Description |
| --- | --- |
| IList<>long | A list of ids (never null). |

### SetIdentifiersAsync(IEnumerable<string>)

Sets the ids on the relations values based on the given identifiers.

In case of an [IToManyRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itomanyrelation.html), the list of ids will be set on the relation.

In case of an [IToOneRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itoonerelation.html), `identifiers` can have at most one value. If the list is empty then the value will be set to null.

#### Declaration

```csharp
Task SetIdentifiersAsync(IEnumerable<string> identifiers)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | identifiers | Identifiers. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

### SetIds(IEnumerable<long>)

Sets the ids on the relations values. The values should be strictly positive.

In case of an [IToManyRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itomanyrelation.html), the list of ids will be set on the relation.

In case of an [IToOneRelation](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itoonerelation.html), `ids` can have at most one value. If the list is empty then the value will be set to null.

#### Declaration

```csharp
void SetIds(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | Ids. |
