API reference and troubleshooting
On this page
SQLite example · Bulk API selection
Core types
| API | Responsibility |
|---|---|
ConnectionConfig | Connection ID, type, string, timeout and binding settings |
OrmClient | Single/multiple database entry point; sync/async disposal |
DbProviderFactory, IDbProvider | Provider registration and capability boundaries |
EntityInfo | Mapping metadata |
CodeFirst, DbMaintenance | Provider-specific schema operations |
Ado, Aop | Raw commands and execution callbacks |
Operations
| API | Purpose |
|---|---|
Queryable<T>() | Conditions, sorting, projection, paging and streaming |
Insertable, InsertableRange | Single/batch insertion |
Updatable<T>, Updatable(entity), UpdatableRange | Conditional/entity updates |
Deletable<T>, Deletable(entity) | Conditional/entity deletion |
Savable | Insert or update with match/update column control |
BulkCopy<T> | Bulk insert, update and merge |
UseTranAsync and generic overload | Automatic transactions |
GetConnection, GetClientForEntity<T> | Database routing |
CopyNew, CopyCurrentConnection | Independent clients |
Query terminal methods
Construction and methods such as Where compose a query. Terminal methods execute it. The optional cancellationToken defaults to default; pass it explicitly when cancellation is required.
| Method | Return type | Parameters and behavior |
|---|---|---|
ToListAsync(...) | Task<List<T>> | Materializes all matches; limit large result sets first |
FirstAsync(...) | Task<T?> | Default value on no match; order explicitly when the first row matters |
AnyAsync(...) | Task<bool> | Tests existence without loading a complete entity list |
CountAsync(...) | Task<int> | Count under current filters |
ToPageListAsync(pageNumber, pageSize, ...) | Task<PagedList<T>> | One-based pages; values below 1 become page 1 / size 10; no application size cap |
ToCursorPageAsync(pageSize, cursor, ...) | Task<CursorPage<T>> | Start with cursor = null, continue with NextCursor; keep query conditions unchanged |
ToAsyncEnumerable(...) | IAsyncEnumerable<T> | Lazy consumption; keep the client, connection and reader alive through enumeration |
ToTimeBucketListAsync(time, value, state, query, ...) | Task<List<OrmTimeBucketResult<TValue>>> | Single-property selectors and OrmTimeBucketQuery; bucket width uses milliseconds |
See queries for paging and cursors, and aggregation for time buckets and quality flags.
ToSql() returns (string Sql, Dictionary<string, object?> Parameters) without executing the query. Observe execution duration and results through execution callbacks.
UseTranAsync(Func<Task> action, cancellationToken, isolationLevel) returns Task. The generic overload accepts Func<Task<T>> and returns Task<T>. Success commits; an exception or cancellation attempts rollback and is rethrown. The transaction token is not injected into operations inside action; pass it to each operation. See transactions.
Troubleshooting
Missing provider. Install the matching package and verify registration assets reach the actual host. Core alone does not contain every driver.
Concurrent reader/connection errors. Check for a singleton shared client or commands issued before enumeration finishes. Use independent units of work.
A route uses the default database. Validate ConfigId: unknown IDs fall back to the current client.
Upsert conflicts. Check actual unique keys, constraints, duplicate input keys and transaction isolation. Application existence checks do not replace unique indexes.
Cursor rejects sorting or projection. Cursor paging requires full entities and internal key ordering. Use ordinary paging for separately ordered presentation.
Types change after database migration. Review column definitions, enums, nulls, time kinds, parameters and provider semantics. Changing a connection string does not migrate data contracts.
Source
The core is in TORM/src/TORM, especially Client, Queryable, write providers, BulkCopy and Ado. Database implementations live in their provider projects. See the separate time-series contract.