Skip to Content
TORMAPI reference and troubleshooting

API reference and troubleshooting

On this page

SQLite example · Bulk API selection

Core types

APIResponsibility
ConnectionConfigConnection ID, type, string, timeout and binding settings
OrmClientSingle/multiple database entry point; sync/async disposal
DbProviderFactory, IDbProviderProvider registration and capability boundaries
EntityInfoMapping metadata
CodeFirst, DbMaintenanceProvider-specific schema operations
Ado, AopRaw commands and execution callbacks

Operations

APIPurpose
Queryable<T>()Conditions, sorting, projection, paging and streaming
Insertable, InsertableRangeSingle/batch insertion
Updatable<T>, Updatable(entity), UpdatableRangeConditional/entity updates
Deletable<T>, Deletable(entity)Conditional/entity deletion
SavableInsert or update with match/update column control
BulkCopy<T>Bulk insert, update and merge
UseTranAsync and generic overloadAutomatic transactions
GetConnection, GetClientForEntity<T>Database routing
CopyNew, CopyCurrentConnectionIndependent 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.

MethodReturn typeParameters 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.