Color scheme: Dark
You are here: start » en » Documentation » Data integration and data access » WKL Database Gateway » .NET client Wkl.Data.Gateway.Client—overview » Reference » API reference

API reference

Applies to client 0.2.1 with the contract package Wkl.Data.Gateway.Contracts 0.6.0. The client's types are in the namespace Wkl.Data.Gateway.Client, the contract's in Wkl.Data.Gateway.Contracts.

Registration

MethodEffect
services.AddGatewayClient(IConfiguration section)Binds the configuration to the section you pass, usually configuration.GetSection(GatewayClientOptions.SectionName)
services.AddGatewayClient(Action<GatewayClientOptions> configure)The same, with settings from code

Both register IGatewayClient (implementation GatewayHttpClient, one per application), the validation of the settings at startup, and two named HTTP clients for reading and calling, each with its own time limit. To replace the default correlation source, register your own IGatewayCorrelationSource before the call; the default uses the trace ID (TraceId) of the current Activity in W3C format, the Id of an Activity in the older hierarchical format, or a new GUID if there's no Activity.

IGatewayClient

MethodPurposeResult
ReadAsync<TRow>(GatewayQuery query, IReadOnlyDictionary<string, string>? arguments = null, CancellationToken ct = default)Reads a window from a table, view, or function. Use arguments only for a function: name and value of each parameter, as textGatewayPage<TRow>
InvokeAsync<TRow>(GatewayRoutineRequest request, CancellationToken ct = default)Calls a procedureGatewayRoutineResult<TRow>

Each method sends exactly one request. If it fails, the method throws GatewayRequestException (see A request fails with `GatewayRequestException`); a cancellation through the caller's CancellationToken arrives as OperationCanceledException.

Row type TRow. Rows are read with System.Text.Json. Column names are matched, case-insensitively, against the snake_case form of the property names (LastChangedUtc reads last_changed_utc). A column whose name differs needs [JsonPropertyName("…")] with the name the database uses. With JsonElement as TRow, each row is read unchanged.

What is read

GatewayResource

new GatewayResource(string databaseAlias, GatewayResourceKind kind, string name)

ParameterMeaning
databaseAliasName of the data source in the service, not the name of the database
kindTable, View, Function, or Procedure
nameobject or schema.object

GatewayQuery

new GatewayQuery(resource, select = null, filter = null, orderBy = null, skip = 0, top = null, includeTotalCount = false)

ParameterMeaning
resourceTable, view, or function. A procedure is rejected (ArgumentException)
selectColumns to read. Empty: all columns the service offers
filterCondition, see below
orderBySequence of GatewaySortField(string field, GatewaySortDirection direction) with Ascending or Descending
skipRows to skip. Not negative
topRequested window size, greater than zero. The service caps it at its maximum; without it, the service uses its default
includeTotalCountAlso asks the service to count how many rows the filter matches in total

Filters (GatewayFilter)

KindConstructionMeaning
Comparisonnew GatewayFilter.Comparison(field, op, value)op is Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, Contains, StartsWith, or EndsWith. The three text searches require a string. value must not be null—use the null check for missing values
Field comparisonnew GatewayFilter.FieldComparison(field, op, otherField)Compares two columns of the same row; equality and ordering only
Null checknew GatewayFilter.NullCheck(field, expectNull)true: the column is empty; false: the column has a value
Membershipnew GatewayFilter.Membership(field, values)The column equals one of the values; 1 to 20,000 values (MaxValues)
Logicalnew GatewayFilter.Logical(GatewayLogicalConnective.And or Or, operands)At least one operand
Negationnew GatewayFilter.Negation(operand)Inverts the condition

A filter can be nested at most ten levels deep (GatewayFilter.MaxDepth).

Values. The client transmits bool, string, char, integers up to 64 bits, decimal, double, float, DateTime (without a time zone), DateTimeOffset, DateOnly, TimeOnly, and Guid. Any other type—enumerations, byte arrays, your own classes—is rejected with MalformedRequest before a request leaves the machine. Pass an enumeration explicitly as a number or as a name, depending on what the column stores.

Identifiers

Alias, object, column, and parameter names start with a letter or _, followed by letters, digits, _, @, #, or $; at most 128 characters per part. An invalid name throws ArgumentException when the object is created; an invalid argument name throws it when you call ReadAsync. The service keeps only letters, digits, and _ unchanged and encodes every other character, including @, #, and $. If a column's name in the database contains such characters (such as Value$, Weight (kg), or A&B), use the encoded form in select, filter, and orderBy, for example Value_x0024_ or A_x0026_B; the rule is described in the data service documentation under “Timestamps, numbers, and names.” The response carries the name the database uses.

What is called

GatewayRoutineRequest

new GatewayRoutineRequest(GatewayResource resource, IReadOnlyDictionary<string, object?>? arguments = null)

resource must be a procedure; otherwise ArgumentException. The arguments travel as JSON in the body; null and the values listed under “Values” are allowed.

What comes back

GatewayPage<TRow>

PropertyMeaning
RowsThe rows that were read
RequestedWindowSizeThe window size the service read with
TotalCountTotal number of matches; null if nobody counted—not the same as 0
HasMorePotentiallytrue if the window is full; then there may be more, and you read the next window with skip

GatewayRoutineResult<TRow>

PropertyMeaning
RowsRows of the procedure's first result set
AffectedRowCountRows changed, if the procedure returned no result set; otherwise null
ReturnedRowstrue if the procedure returned a result set

GatewayRequestException

Carries a GatewayProblem in Problem with Kind, Message, CorrelationId, EngineMessages, HttpStatusCode, and IsTransient. What each kind means and how to handle it is described in A request fails with `GatewayRequestException`.

en/wiki/data-conectivity/database-gateway/client/reference/api.txt · Last modified: by Wolfgang van der Stille