Table of Contents

Struct SqlScalarQueryResult

Namespace
LfrlAnvil.Sql.Statements
Assembly
LfrlAnvil.Sql.Core.dll

Represents a type-erased scalar query reader result.

public readonly struct SqlScalarQueryResult : IEquatable<SqlScalarQueryResult>
Implements
Inherited Members

Constructors

SqlScalarQueryResult(object?)

Creates a new SqlScalarQueryResult instance with a Value.

public SqlScalarQueryResult(object? value)

Parameters

value object

Underlying value.

Fields

Empty

Represents a result without a Value.

public static readonly SqlScalarQueryResult Empty

Field Value

SqlScalarQueryResult

Properties

HasValue

Specifies whether or not any value was read.

public bool HasValue { get; }

Property Value

bool

Value

Underlying value.

public object? Value { get; }

Property Value

object

Methods

Equals(SqlScalarQueryResult)

Indicates whether the current object is equal to another object of the same type.

[Pure]
public bool Equals(SqlScalarQueryResult other)

Parameters

other SqlScalarQueryResult

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

[Pure]
public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

[Pure]
public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetValue()

Returns the underlying value.

[Pure]
public object? GetValue()

Returns

object

Value.

Exceptions

InvalidOperationException

When HasValue is equal to false.

GetValueOrDefault(object?)

Returns the underlying value if it exists, otherwise returns the provided default value.

[Pure]
public object? GetValueOrDefault(object? @default)

Parameters

default object

Default value.

Returns

object

Value if it exists, otherwise provided default value.

ToString()

Returns a string representation of this SqlScalarQueryResult instance.

[Pure]
public override string ToString()

Returns

string

String representation.

Operators

operator ==(SqlScalarQueryResult, SqlScalarQueryResult)

Checks if a is equal to b.

[Pure]
public static bool operator ==(SqlScalarQueryResult a, SqlScalarQueryResult b)

Parameters

a SqlScalarQueryResult

First operand.

b SqlScalarQueryResult

Second operand.

Returns

bool

true when operands are equal, otherwise false.

operator !=(SqlScalarQueryResult, SqlScalarQueryResult)

Checks if a is not equal to b.

[Pure]
public static bool operator !=(SqlScalarQueryResult a, SqlScalarQueryResult b)

Parameters

a SqlScalarQueryResult

First operand.

b SqlScalarQueryResult

Second operand.

Returns

bool

true when operands are not equal, otherwise false.