Struct QuerySelectCommand<TValue, TConverter>
- Namespace
- DynaSharp
- Assembly
- DynaSharp.dll
A Query of one attribute, as Select<TValue, TConverter>(Attr<TValue, TConverter>) leaves it. Nothing can be added any more, which the type enforces, so Filter,
Limit, Descending and the other clauses come before Select: what is left is to send it, with the same methods as QueryCommand<T>.
public readonly ref struct QuerySelectCommand<TValue, TConverter> where TConverter : IDynamoDbConverter<TValue>
Type Parameters
TValueThe type of the attribute, nullable for a handle of a nullable property.
TConverterThe converter that reads it.
- Inherited Members
Remarks
An attribute that an item does not have follows the type of the handle: null for a nullable one, an empty set for a set, and otherwise a DynamoDbMappingException, which holds no key, because only the attribute came back. Keys and all else stay out of the response, and the discriminator too, unless the key condition stands where its filter would.
Methods
PageAsync(ContinuationToken, CancellationToken)
Reads one page, as PageAsync(ContinuationToken, CancellationToken) does, with the values in Items.
public ValueTask<Page<TValue>> PageAsync(ContinuationToken after = default, CancellationToken cancellationToken = default)
Parameters
afterContinuationTokenThe position to continue from, or
defaultfor the first page. It must come from the same query. AContinuationToken?passes asafter ?? default.cancellationTokenCancellationTokenCancels the call.
Returns
Exceptions
- InvalidOperationException
The command was already sent or rendered.
- ObjectDisposedException
The client is disposed.
- FormatException
afterdoes not fit what TokenSigner says: a client that signs gets a plain token that came as text, or one whose signature does not hold for this read; a client that does not sign gets a signed one. The message quotes nothing of the token, and no request goes out.- ValidationException
DynamoDB rejects the request, for example a position of another query; the exception shows the expressions.
- ResourceNotFoundException
The table does not exist.
- DynamoDbMappingException
An item has no such attribute and the handle cannot be null, or its value cannot be read as
TValue.- DynamoDbException
DynamoDB returns any other error; a throttling or server error only after the last attempt.
PageAsync(CancellationToken)
Reads the first page, as PageAsync(ContinuationToken, CancellationToken) does at the default position, for a caller that has a token and no position yet.
public ValueTask<Page<TValue>> PageAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancels the call. It has no default, because
PageAsync()belongs to the overload with the position.
Returns
Exceptions
- InvalidOperationException
The command was already sent or rendered.
- ObjectDisposedException
The client is disposed.
- ValidationException
DynamoDB rejects the request; the exception shows the expressions.
- ResourceNotFoundException
The table does not exist.
- DynamoDbMappingException
An item has no such attribute and the handle cannot be null, or its value cannot be read as
TValue.- DynamoDbException
DynamoDB returns any other error; a throttling or server error only after the last attempt.
PagesAsync(CancellationToken)
Reads all pages as they come, as PagesAsync(CancellationToken) does, with the values in Items.
public IAsyncEnumerable<Page<TValue>> PagesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels the read, as does
WithCancellationon the result.
Returns
- IAsyncEnumerable<Page<TValue>>
The pages, which can be enumerated once.
Exceptions
- InvalidOperationException
The command was already sent or rendered.
ToRequestJson()
Renders the body of the first page, as DynamoDB JSON, without sending it. It ends the command, and is meant for tests and debugging. It shows what goes out, and the text contains the key and the values.
public string ToRequestJson()
Returns
- string
The request body.
Exceptions
- InvalidOperationException
The command was already sent or rendered.
ValueAsync(CancellationToken)
Reads the attribute of the first item that matches, in the order of the query, and stops there, as ItemAsync(CancellationToken) does, with what it says about Limit.
Found tells no match from a value, also for a handle that cannot be null.
public ValueTask<SelectResult<TValue>> ValueAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels the read. It is looked at per page.
Returns
- ValueTask<SelectResult<TValue>>
The result. Await it once.
Exceptions
- InvalidOperationException
The command was already sent or rendered.
- ObjectDisposedException
The client is disposed.
- ValidationException
DynamoDB rejects the request; the exception shows the expressions.
- ResourceNotFoundException
The table does not exist.
- DynamoDbMappingException
An item of the page has no such attribute and the handle cannot be null, or its value cannot be read as
TValue, which counts for all items of that page, not only for the first.- DynamoDbException
DynamoDB returns any other error; a throttling or server error only after the last attempt.
ValuesAsync(CancellationToken)
Reads the attribute of all items of all pages as they come, as ItemsAsync(CancellationToken) reads the items.
public IAsyncEnumerable<TValue> ValuesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels the read, as does
WithCancellationon the result. It is looked at per page.
Returns
- IAsyncEnumerable<TValue>
The values, which can be enumerated once; a second enumeration throws InvalidOperationException, so build the command again to read again.
Exceptions
- InvalidOperationException
The command was already sent or rendered.