# DataSourceRegistry Class

> DataSourceRegistry class in the .NET API: Server-only logical connection/query registry with bounded scoped caching and per-query serialization.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Data`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Data.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Data > DataSourceRegistry Class
- **1354 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/llms-full.txt

---

Server-only logical connection/query registry with bounded scoped caching and per-query serialization. Own its lifetime in the application; it never disposes providers or database pools. No endpoint is exposed automatically.

### Syntax

```csharp
public class DataSourceRegistry
```

### Members

#### Constructors

| Constructor | Description |
|---|---|
| [Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/constructor/llms-full.txt) |  |

#### Methods

| Method | Description |
|---|---|
| [GetCapabilities](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/getcapabilities-method/llms-full.txt) | Returns capabilities without exposing a provider instance or its connection settings. |
| [QueryAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/queryasync-method/llms-full.txt) | Executes an approved logical query. Authorize the caller before invoking this method. Timeouts/cancellation include queue wait. Cache keys include scope, page and canonicalized parameters. |
| [Register](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/register-method/llms-full.txt) | Registers/replaces a server-approved query. Replacement creates a fresh cache; in-flight readers finish on the old instance. |
| [Remove](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/remove-method/llms-full.txt) | Removes a query and its cache; subsequent requests fail. Already-running requests can finish. |

### Examples

Create a working report from bounded HTTP sales data. Supply an application-owned HttpClient and service URL; scope cached data to its actual audience.

```csharp
using System.Net.Http;
using TXTextControl.TXSheetControl.Data;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildDataSourceRegistryExampleAsync(ServerSheetControl control, HttpClient client, Uri serviceBase)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var source = new HttpDataSource(client, request => new HttpRequestMessage(HttpMethod.Get, new Uri(serviceBase, "sales?offset=" + request.Offset + "&limit=" + request.Limit)), ["Region", "Revenue"]);
    var registry = new DataSourceRegistry();
    registry.Register("sales-service", "regional-sales", source);

    var request = new DataRequest { Offset = 0, Limit = 100, Parameters = new Dictionary<string, object?> { ["year"] = 2026 } };
    var options = new DataQueryOptions { Timeout = TimeSpan.FromSeconds(15), CacheDuration = TimeSpan.FromMinutes(1), CacheScope = "public-regional-sales" };
    using var binding = new WorkbookDataBinding(book, registry);
    await binding.RefreshRangeAsync(sheet.Range("A1:B101"), "sales-service", "regional-sales", request, options);
    await sheet.Range("A1:B1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    return await control.SaveAsync(StreamType.PDF);
}
```

### See Also

- [TXTextControl.TXSheetControl.Data Namespace](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)

---

## In This Section

- [DataSourceRegistry Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/constructor/llms-full.txt): DataSourceRegistry constructor in the TX Sheet Control .NET API, with its syntax, a C# example and remarks on awaiting tasks and handles.
- [DataSourceRegistry.GetCapabilities Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/getcapabilities-method/llms-full.txt): DataSourceRegistry.GetCapabilities method in the .NET API: Returns capabilities without exposing a provider instance or its connection settings.
- [DataSourceRegistry.QueryAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/queryasync-method/llms-full.txt): DataSourceRegistry.QueryAsync method in the TX Sheet Control .NET API: Executes an approved logical query. Authorize the caller before invoking this method.
- [DataSourceRegistry.Register Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/register-method/llms-full.txt): DataSourceRegistry.Register method in the TX Sheet Control .NET API: Registers/replaces a server-approved query. Replacement creates a fresh cache.
- [DataSourceRegistry.Remove Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/remove-method/llms-full.txt): DataSourceRegistry.Remove method in the TX Sheet Control .NET API: Removes a query and its cache; subsequent requests fail.

---

## Nearby

- **Previous:** [DataSourceCapabilities Enumeration](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourcecapabilities/llms-full.txt)
- **Next:** [DataSourceRegistry Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasourceregistry/constructor/llms-full.txt)
