---
url: /nestjs-odata/api/generated/functions/annotateEntity.md
---
# Function: annotateEntity()

> **annotateEntity**(`entity`, `ctx`): `Record`<`string`, `unknown`>

Defined in: [response/odata-annotation.builder.ts:63](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/response/odata-annotation.builder.ts#L63)

Annotate a single entity object with OData v4 metadata annotations.

Adds:

* @odata.id — canonical URL for the entity (RESP-04)
* @odata.type — qualified type name with namespace prefix (RESP-05)
* {navProp}@odata.navigationLink — for each navigation property (RESP-06)

Returns the entity unchanged if it is null, undefined, or not an object.

This function is pure — it never mutates the input entity.

## Parameters

### entity

`Record`<`string`, `unknown`>

The entity object to annotate

### ctx

[`AnnotationContext`](../interfaces/AnnotationContext.md)

The annotation context (service root, entity set name, entity type, namespace)

## Returns

`Record`<`string`, `unknown`>
