# IDataSource Interface

> IDataSource interface in the TX Sheet Control .NET API: Server-owned asynchronous query. Implementations own authorization, credentials and query definitions.

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

---

Server-owned asynchronous query. Implementations own authorization, credentials and query definitions. Registered instances must support concurrent requests; returned snapshots are immutable.

### Syntax

```csharp
public interface IDataSource
```

### Members

#### Properties

| Property | Description |
|---|---|
| [Capabilities](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/capabilities-property/llms-full.txt) | Describes supported request operations. |

#### Methods

| Method | Description |
|---|---|
| [QueryAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/queryasync-method/llms-full.txt) | Returns no more than request.Limit rows. Cancellation must cover opening, reading and disposal. |

### Examples

Request a bounded snapshot from an application-provided data source, honor its paging capability and write the returned columns and rows into a report.

```csharp
using TXTextControl.TXSheetControl.Data;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> ExportProviderDataAsync(ServerSheetControl control, IDataSource source)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var request = new DataRequest { Limit = 100 };

    if (!source.Capabilities.HasFlag(DataSourceCapabilities.Paging)) request = new DataRequest();

    var data = await source.QueryAsync(request);

    if (data.Rows.Count == 0) return await control.SaveAsync(StreamType.PDF);

    var lastColumn = "";

    for (var index = data.Columns.Count; index > 0; index /= 26) { index--; lastColumn = (char)(65 + index % 26) + lastColumn; }

    await sheet.Range("A1:" + lastColumn + "1").SetValuesAsync([data.Columns.Cast<object?>().ToArray()]);
    await sheet.Range("A2:" + lastColumn + (data.Rows.Count + 1)).SetValuesAsync(data.Rows.Select(row => row.ToArray()).ToArray());
    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

- [IDataSource.Capabilities Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/capabilities-property/llms-full.txt): IDataSource.Capabilities property in the TX Sheet Control .NET API: Describes supported request operations. Includes the syntax and a C# example.
- [IDataSource.QueryAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/queryasync-method/llms-full.txt): IDataSource.QueryAsync method in the TX Sheet Control .NET API: Returns no more than request.Limit rows. Includes the syntax and a C# example.

---

## Nearby

- **Previous:** [HttpDataSource.QueryAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/queryasync-method/llms-full.txt)
- **Next:** [IDataSource.Capabilities Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/capabilities-property/llms-full.txt)
