> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/13.latest/reference/management/models/relation.md).

# Relation

Represents a Relation between two items.

Represents a Relation between two items.

* **Namespace:** `Umbraco.Cms.Core.Models`
* **Assembly:** `Umbraco.Core.dll`

All samples in this document will require references to the following dll:

* Umbraco.Core.dll

All samples in this document will require the following using statement:

```csharp
using Umbraco.Cms.Core.Models;
```

## Constructors

### new Relation(int parentId, int childId, IRelationType relationType)

Constructor for creating a new Relation object. The necessary parameters are the Id of the parent item as an `int`, the Id of the child as an `int` and the relationType as `IRelationType`.

### new Relation(int parentId, int childId, Guid parentObjectType, Guid childObjectType, IRelationType relationType)

A second constructor exists but it should not be used because it is used to reconstruct a relation from the data source.

## Properties

### .ChildId

Gets or sets the Child Id of the Relation (Destination)

```csharp
// Given a `IRelationService` object get Relation by its Id and return ChildId
var relation = relationService.GetById(1234);
return relation.ChildId;
```

### .Comment

Gets or sets a comment for the Relation

```csharp
// Given a `IRelationService` object get Relation by its Id and return Comment
var relation = relationService.GetById(1234);
return relation.Comment;
```

### .ParentId

Gets or sets the Parent Id of the Relation (Source)

```csharp
// Given a `IRelationService` object get Relation by its Id and return ParentId
var relation = relationService.GetById(1234);
return relation.ParentId;
```

### .RelationType

Gets or sets the RelationType for the Relation

```csharp
// Given a `IRelationService` object get Relation by its Id and return RelationType
var relation = relationService.GetById(1234);
return relation.RelationType;
```

### .RelationTypeId

Gets the Id of the RelationType that this Relation is based on.

```csharp
// Given a `IRelationService` object get Relation by its Id and return RelationTypeId
var relation = relationService.GetById(1234);
return relation.RelationTypeId;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-cms/13.latest/reference/management/models/relation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
