# RetentionPolicy

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.retentionpolicy/
> Summary: RetentionPolicy: An age- and volume-based retention rule for a target.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

An age- and volume-based retention rule for a target.

```csharp
public sealed record RetentionPolicy : IEquatable<RetentionPolicy>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.retentionpolicy/">RetentionPolicy</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;RetentionPolicy&gt;</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

If no record exists, nothing is deleted for the target (see
`TraconRetentionOptions`' configuration-based defaults — they
take effect only when the database has no record).

## Constructors

### <a id="Tracon_RetentionPolicy__ctor"></a> RetentionPolicy\(\)

```csharp
public RetentionPolicy()
```

## Properties

### <a id="Tracon_RetentionPolicy_Archive"></a> Archive

Whether to archive with `IArchiveSink` before deleting. If no
sink is registered, no row is deleted even if this field is
[true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

```csharp
public bool Archive { get; init; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_RetentionPolicy_CreatedAt"></a> CreatedAt

The creation time (UTC).

```csharp
public required DateTimeOffset CreatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

### <a id="Tracon_RetentionPolicy_Enabled"></a> Enabled

Whether the policy is enabled.

```csharp
public bool Enabled { get; init; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_RetentionPolicy_Id"></a> Id

The policy identifier.

```csharp
public required Guid Id { get; init; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

### <a id="Tracon_RetentionPolicy_MaxAgeDays"></a> MaxAgeDays

Rows older than this age are candidates for deletion. If
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), age-based deletion does not apply (only
`MaxRows`, if set, applies).

```csharp
public int? MaxAgeDays { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)?

### <a id="Tracon_RetentionPolicy_MaxRows"></a> MaxRows

The maximum number of rows to keep in the target table. The oldest
rows over the limit are deleted. If [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null),
volume-based deletion does not apply (only `MaxAgeDays`,
if set, applies).

```csharp
public long? MaxRows { get; init; }
```

#### Property Value

 [long](https://learn.microsoft.com/dotnet/api/system.int64)?

### <a id="Tracon_RetentionPolicy_Target"></a> Target

The target table name. See [RetentionTargets](/api/tracon.retentiontargets/).

```csharp
public required string Target { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_RetentionPolicy_TenantId"></a> TenantId

The tenant identifier. `"*"` means the default for all tenants.

```csharp
public required string TenantId { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_RetentionPolicy_UpdatedAt"></a> UpdatedAt

The last-updated time (UTC).

```csharp
public required DateTimeOffset UpdatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

## Methods

### <a id="Tracon_RetentionPolicy_Equals_System_Object_"></a> Equals\(object?\)

```csharp
public override bool Equals(object? obj)
```

#### Parameters

`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_RetentionPolicy_Equals_Tracon_RetentionPolicy_"></a> Equals\(RetentionPolicy?\)

```csharp
public bool Equals(RetentionPolicy? other)
```

#### Parameters

`other` [RetentionPolicy](/api/tracon.retentionpolicy/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_RetentionPolicy_GetHashCode"></a> GetHashCode\(\)

```csharp
public override int GetHashCode()
```

#### Returns

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_RetentionPolicy_ToString"></a> ToString\(\)

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Operators

### <a id="Tracon_RetentionPolicy_op_Equality_Tracon_RetentionPolicy_Tracon_RetentionPolicy_"></a> operator ==\(RetentionPolicy?, RetentionPolicy?\)

```csharp
public static bool operator ==(RetentionPolicy? left, RetentionPolicy? right)
```

#### Parameters

`left` [RetentionPolicy](/api/tracon.retentionpolicy/)?

`right` [RetentionPolicy](/api/tracon.retentionpolicy/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_RetentionPolicy_op_Inequality_Tracon_RetentionPolicy_Tracon_RetentionPolicy_"></a> operator \!=\(RetentionPolicy?, RetentionPolicy?\)

```csharp
public static bool operator !=(RetentionPolicy? left, RetentionPolicy? right)
```

#### Parameters

`left` [RetentionPolicy](/api/tracon.retentionpolicy/)?

`right` [RetentionPolicy](/api/tracon.retentionpolicy/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
