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
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
Data
The data returned.
public object Data { get; set; }
Property Value
ExceptionMessages
Gets any exception messages that might have occurred.
public IEnumerable<string> ExceptionMessages { get; set; }
Property Value
ExceptionStackTrace
Gets the stack trace if there was an exception.
public string ExceptionStackTrace { get; set; }
Property Value
HasExceptions
Gets whether there are any exceptions that occurred.
public bool HasExceptions { get; }
Property Value
IsAuthorized
Gets whether the query was authorized to execute.
public bool IsAuthorized { get; set; }
Property Value
IsReady
Gets whether the query result is ready.
public bool IsReady { get; set; }
Property Value
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
IsValid
Gets whether the query is valid.
public bool IsValid { get; }
Property Value
Paging
Gets or inits the PagingInfo for the query.
public PagingInfo Paging { get; set; }
Property Value
ValidationResults
Gets the validation results for the query.
public IEnumerable<ValidationResult> ValidationResults { get; set; }
Property Value
Methods
Error(CorrelationId, Exception)
Creates a new QueryResult representing an error.
public static QueryResult Error(CorrelationId correlationId, Exception exception)
Parameters
correlationIdCorrelationIdThe CorrelationId associated with the query.
exceptionExceptionThe exception.
Returns
Error(CorrelationId, string)
Creates a new QueryResult representing an error.
public static QueryResult Error(CorrelationId correlationId, string message)
Parameters
correlationIdCorrelationIdThe CorrelationId associated with the query.
messagestringThe error message.
Returns
FromException(CorrelationId, Exception)
Creates a new QueryResult from an exception.
public static QueryResult FromException(CorrelationId correlationId, Exception exception)
Parameters
correlationIdCorrelationIdThe CorrelationId associated with the query.
exceptionExceptionThe exception to convert.
Returns
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
queryResultsQueryResult[]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
correlationIdCorrelationIdThe CorrelationId associated with the query.
nameFullyQualifiedQueryNameThe name of the query that is missing a performer.
Returns
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
correlationIdCorrelationIdThe 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
correlationIdCorrelationIdThe 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
correlationIdCorrelationIdThe CorrelationId associated with the query.
Returns
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
correlationIdCorrelationIdThe CorrelationId associated with the query.
memberNamestringThe name of the field that failed validation.
messagestringThe validation error message.