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

> **ODataController**(`entitySetName`, `options?`): `ClassDecorator`

Defined in: [decorators/odata-controller.decorator.ts:33](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/decorators/odata-controller.decorator.ts#L33)

Class decorator for OData controllers.

Composes:

1. Controller(path) — NestJS route prefix, defaults to entitySetName
2. SetMetadata(ODATA_CONTROLLER_KEY, entitySetName) — marks as OData controller
   (used by ODataModule.forRoot() to patch PATH_METADATA with serviceRoot)

Per D-11: Separate from @Controller() — sets entity context and route prefix.
Per D-17: The service root prefix is applied by ODataModule.forRoot({ controllers })
via Reflect.defineMetadata(PATH_METADATA) — the same pattern used by MetadataController.
The controller is initially registered with just the entitySetName as path;
the module prepends serviceRoot during forRoot().

Note: ODataResponseInterceptor and ODataExceptionFilter are NOT applied at class level.
Each CRUD method decorator (@ODataGet, @ODataPost, @ODataPatch, @ODataDelete, @ODataGetByKey)
applies these per-method. This avoids double-wrapping when method and class decorators
are both used.

## Parameters

### entitySetName

`string`

The OData entity set name (e.g. 'Products')

### options?

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

Optional configuration

Zero TypeORM imports — per PKG-01 architecture constraint.

## Returns

`ClassDecorator`
