---
title: "Class ToOneRelation<TRelation>"
slug: "sdk--stylelabs.m.sdk.models.typed.fields.toonerelation-1"
abstract: ""
---
# Class ToOneRelation<TRelation>

Defines a relation that is associated with only one entity.

## Inheritance

object

ToOneRelation<TRelation>

[ReadOnlyToOneRelation<TRelation>](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.typed.fields.readonlytoonerelation-1.html)

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

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public class ToOneRelation<TRelation> where TRelation : class, IToOneRelation
```

## Type Parameters

| Name | Description |
| --- | --- |
| TRelation | The type of the relation. |

## Constructors

### ToOneRelation(IMClient, TypedEntityWrapper, string)

Initializes a new instance of the [ToOneRelation<TRelation>](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.typed.fields.toonerelation-1.html) class.

#### Declaration

```csharp
public ToOneRelation(IMClient client, TypedEntityWrapper wrapper, string relationName)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [IMClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.imclient.html) | client | The [IMClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.imclient.html) instance. |
| [TypedEntityWrapper](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.utilities.typedentitywrapper.html) | wrapper | The typed entity wrapper. |
| string | relationName | The property name. |

## Fields

### Client

The client.

#### Declaration

```csharp
protected readonly IMClient Client
```

#### Field Value

| Type | Description |
| --- | --- |
| [IMClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.imclient.html) |  |

### Relation

The relation.

#### Declaration

```csharp
protected readonly TRelation Relation
```

#### Field Value

| Type | Description |
| --- | --- |
| TRelation |  |

## Properties

### Id

Gets or sets the value of the relation.

#### Declaration

```csharp
public virtual long? Id { get; set; }
```

#### Property Value

| Type | Description |
| --- | --- |
| long |  |

## Methods

### GetEntityAsync(EntityLoadConfiguration)

Gets the related entity as an [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html).

#### Declaration

```csharp
public Task<IEntity> GetEntityAsync(EntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [EntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) | loadConfiguration | The [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | A list of [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html). |

### GetEntityAsync<TEntity>(EntityLoadConfiguration)

Gets the related entity as a typed [ITypedEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.itypedentity.html).

#### Declaration

```csharp
public Task<TEntity> GetEntityAsync<TEntity>(EntityLoadConfiguration loadConfiguration = null) where TEntity : ITypedEntity
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [EntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) | loadConfiguration | The [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html). |

#### Returns

| Type | Description |
| --- | --- |
| Task<> | A list of [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html). |

#### Type Parameters

| Name | Description |
| --- | --- |
| TEntity | The type of the entity. |
