Class QueryResult

Namespace
Cratis.Arc.Queries
Assembly
Cratis.Arc.Core.dll

Carries admission-only data back across the asynchronous query pipeline boundary without serializing it.

public class QueryResult
Inheritance
QueryResult
Inherited Members
Extension Methods

Constructors

QueryResult()

public QueryResult()

Properties

ChangeSet

Gets or sets the optional change set describing what changed since the previous update.

public ChangeSet? ChangeSet { get; set; }

Property Value

ChangeSet

Remarks

When set, the client may use this to apply delta updates to its local state instead of replacing the full dataset. When null, the client must treat Data as the complete current snapshot.

CorrelationId

Gets the CorrelationId associated with the command.

public CorrelationId CorrelationId { get; set; }

Property Value

CorrelationId

Data

The data returned.

public object Data { get; set; }

Property Value

object

ExceptionMessages

Gets any exception messages that might have occurred.

public IEnumerable<string> ExceptionMessages { get; set; }

Property Value

IEnumerable<string>

ExceptionStackTrace

Gets the stack trace if there was an exception.

public string ExceptionStackTrace { get; set; }

Property Value

string

HasExceptions

Gets whether there are any exceptions that occurred.

public bool HasExceptions { get; }

Property Value

bool

IsAuthorized

Gets whether the query was authorized to execute.

public bool IsAuthorized { get; set; }

Property Value

bool

IsReady

Gets whether the query result is ready.

public bool IsReady { get; set; }

Property Value

bool

Remarks

An observable query that has not yet produced its first result is not ready. This is a transient state, distinct from a failure: HasExceptions stays false so a caller does not mistake "not produced yet" for a crash. The HTTP layer surfaces it as 202 Accepted rather than an error status.

IsSuccess

Gets whether or not the query executed successfully.

public bool IsSuccess { get; }

Property Value

bool

IsValid

Gets whether the query is valid.

public bool IsValid { get; }

Property Value

bool

Paging

Gets or inits the PagingInfo for the query.

public PagingInfo Paging { get; set; }

Property Value

PagingInfo

ValidationResults

Gets the validation results for the query.

public IEnumerable<ValidationResult> ValidationResults { get; set; }

Property Value

IEnumerable<ValidationResult>

Methods

Error(CorrelationId, Exception)

Creates a new QueryResult representing an error.

public static QueryResult Error(CorrelationId correlationId, Exception exception)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

exception Exception

The exception.

Returns

QueryResult

A QueryResult.

Error(CorrelationId, string)

Creates a new QueryResult representing an error.

public static QueryResult Error(CorrelationId correlationId, string message)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

message string

The error message.

Returns

QueryResult

A QueryResult.

FromException(CorrelationId, Exception)

Creates a new QueryResult from an exception.

public static QueryResult FromException(CorrelationId correlationId, Exception exception)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

exception Exception

The exception to convert.

Returns

QueryResult

A QueryResult.

Remarks

An exception implementing IValidationFailure represents invalid client input and becomes a validation failure (mapping to HTTP 400); any other exception becomes an error result (HTTP 500). This lets code running inside the pipeline reject a query as invalid without knowing how the result is serialized.

MergeWith(params QueryResult[])

Merges the results of one or more QueryResult instances into this.

public void MergeWith(params QueryResult[] queryResults)

Parameters

queryResults QueryResult[]

Params of QueryResult to merge with.

MissingPerformer(CorrelationId, FullyQualifiedQueryName)

Creates a new QueryResult representing a missing performer.

public static QueryResult MissingPerformer(CorrelationId correlationId, FullyQualifiedQueryName name)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

name FullyQualifiedQueryName

The name of the query that is missing a performer.

Returns

QueryResult

A QueryResult.

NotReady(CorrelationId)

Creates a new QueryResult representing an observable query that has not yet produced its first result.

public static QueryResult NotReady(CorrelationId correlationId)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

Returns

QueryResult

A QueryResult that is not ready and carries no exception.

Remarks

Use this instead of an error result for the transient "no first result yet" state: it keeps HasExceptions false so a caller does not read a pending observable query as a crash.

Success(CorrelationId)

Represents a successful command result.

public static QueryResult Success(CorrelationId correlationId)

Parameters

correlationId CorrelationId

The correlation ID.

Returns

QueryResult

A successful QueryResult.

Unauthorized(CorrelationId)

Creates a new QueryResult representing an unauthorized query execution.

public static QueryResult Unauthorized(CorrelationId correlationId)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

Returns

QueryResult

A QueryResult.

WithValidationError(CorrelationId, string, string)

Creates a new QueryResult representing a validation error for a specific field.

public static QueryResult WithValidationError(CorrelationId correlationId, string memberName, string message)

Parameters

correlationId CorrelationId

The CorrelationId associated with the query.

memberName string

The name of the field that failed validation.

message string

The validation error message.

Returns

QueryResult

A QueryResult.