# IRepository<TEntity>

`interface` `public`

```csharp
namespace Core.Data.Repositories;

public interface IRepository<TEntity>
    where TEntity : class
```

Defines the standard data access operations for an aggregate.

* **TEntity**: The entity type managed by the repository.

## Methods

{% member id="addasync" %}
```csharp
Task<TEntity> AddAsync(
    TEntity entity,
    CancellationToken cancellationToken = default
)
```

Asynchronously adds a new entity to the repository.

* **entity**: The entity instance to be inserted.
* **cancellationToken**: A token to observe for cancellation requests.

**Returns**: The inserted entity with any database-generated values applied.

{% /member %}

{% member id="update" %}
```csharp
void Update(TEntity entity)
```

Begins tracking the given entity using the Modified state.

* **entity**: The entity instance to update.

{% /member %}
