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
objectUnderlying value.
Fields
Empty
Represents a result without a Value.
public static readonly SqlScalarQueryResult Empty
Field Value
Properties
HasValue
Specifies whether or not any value was read.
public bool HasValue { get; }
Property Value
Value
Underlying value.
public object? Value { get; }
Property Value
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
SqlScalarQueryResultAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe 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
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
objectDefault value.
Returns
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
SqlScalarQueryResultFirst operand.
b
SqlScalarQueryResultSecond 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
SqlScalarQueryResultFirst operand.
b
SqlScalarQueryResultSecond operand.
Returns
- bool
true when operands are not equal, otherwise false.