# IDataSubjectStore

> 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.idatasubjectstore/
> Summary: IDataSubjectStore: The data plane that counts, exports, and erases one data subject's content across the schema.

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

The data plane that counts, exports, and erases one data subject's content
across the schema.

```csharp
public interface IDataSubjectStore
```

## Remarks

The default (in-memory) setup registers `NullDataSubjectStore`, which
always returns an empty result: export and erasure are meaningful only when a
SQL provider is enabled — the same precedent as [IRetentionStore](/api/tracon.iretentionstore/)
and its `NullRetentionStore`.

## Methods

### <a id="Tracon_IDataSubjectStore_EraseAsync_System_String_Tracon_DataSubjectScope_System_Func_System_Collections_Generic_IReadOnlyDictionary_System_String_System_Int32__System_Threading_CancellationToken_System_Threading_Tasks_ValueTask__System_Threading_CancellationToken_"></a> EraseAsync\(string, DataSubjectScope, Func<IReadOnlyDictionary<string, int\>, CancellationToken, ValueTask\>, CancellationToken\)

Deletes a scope's content.

```csharp
ValueTask<IReadOnlyDictionary<string, int>> EraseAsync(string tenantId, DataSubjectScope scope, Func<IReadOnlyDictionary<string, int>, CancellationToken, ValueTask> beforeCommitAsync, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant id.

`scope` [DataSubjectScope](/api/tracon.datasubjectscope/)

The subject's scope.

`beforeCommitAsync` [Func](https://learn.microsoft.com/dotnet/api/system.func\-3)<[IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [int](https://learn.microsoft.com/dotnet/api/system.int32)\>, [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken), [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask)\>

Runs after every delete has executed but BEFORE the change is committed. When
it throws, every delete is rolled back and the exception propagates —
That rule applied here: an erasure that cannot be written to the audit
trail is not applied. The caller uses this to write the audit entry (which
needs the row counts this method computes) while the erasure itself can
still be undone if that write fails.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [int](https://learn.microsoft.com/dotnet/api/system.int32)\>\>

The row count actually deleted per target.

#### Remarks

The content includes the bytes of the scope's attachments. When they live
in [IAttachmentStorage](/api/tracon.iattachmentstorage/), they are deleted after the rows and
BEFORE `beforeCommitAsync` runs. A byte delete that throws
rolls every delete back and propagates, so the audit trail never records
an erasure that did not happen. If the commit fails after the bytes are
gone, a repeat call finishes the erasure: the storage treats a repeat
delete as success.

### <a id="Tracon_IDataSubjectStore_ExportAsync_System_String_Tracon_DataSubjectScope_System_Threading_CancellationToken_"></a> ExportAsync\(string, DataSubjectScope, CancellationToken\)

Reads every column of a scope's content, target by target, as one export document.

```csharp
ValueTask<DataSubjectExport> ExportAsync(string tenantId, DataSubjectScope scope, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant id.

`scope` [DataSubjectScope](/api/tracon.datasubjectscope/)

The subject's scope.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[DataSubjectExport](/api/tracon.datasubjectexport/)\>

The export document.

### <a id="Tracon_IDataSubjectStore_PreviewAsync_System_String_Tracon_DataSubjectScope_System_Threading_CancellationToken_"></a> PreviewAsync\(string, DataSubjectScope, CancellationToken\)

Counts the rows that would be deleted for a scope, by target, without deleting anything.

```csharp
ValueTask<IReadOnlyDictionary<string, int>> PreviewAsync(string tenantId, DataSubjectScope scope, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant id.

`scope` [DataSubjectScope](/api/tracon.datasubjectscope/)

The subject's scope.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [int](https://learn.microsoft.com/dotnet/api/system.int32)\>\>

The row count per target; a target with nothing to delete is present with the value `0`.
