Struct SqlScalarQueryResult<T>
- Namespace
- LfrlAnvil.Sql.Statements
- Assembly
- LfrlAnvil.Sql.Core.dll
Represents a generic scalar query reader result.
public readonly struct SqlScalarQueryResult<T> : IEquatable<SqlScalarQueryResult<T>>
Type Parameters
T
Value type.
- Implements
- Inherited Members
Constructors
SqlScalarQueryResult(T?)
Creates a new SqlScalarQueryResult<T> instance with a Value.
public SqlScalarQueryResult(T? value)
Parameters
value
TUnderlying value.
Fields
Empty
Represents a result without a Value.
public static readonly SqlScalarQueryResult<T> Empty
Field Value
Properties
HasValue
Specifies whether or not any value was read.
public bool HasValue { get; }
Property Value
Value
Underlying value.
public T? Value { get; }
Property Value
- T
Methods
Equals(SqlScalarQueryResult<T>)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(SqlScalarQueryResult<T> other)
Parameters
other
SqlScalarQueryResult<T>An 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 T? GetValue()
Returns
- T
Exceptions
- InvalidOperationException
When HasValue is equal to false.
GetValueOrDefault(T?)
Returns the underlying value if it exists, otherwise returns the provided default
value.
[Pure]
public T? GetValueOrDefault(T? @default)
Parameters
default
TDefault value.
Returns
- T
Value if it exists, otherwise provided
default
value.
ToString()
Returns a string representation of this SqlScalarQueryResult<T> instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator ==(SqlScalarQueryResult<T>, SqlScalarQueryResult<T>)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(SqlScalarQueryResult<T> a, SqlScalarQueryResult<T> b)
Parameters
a
SqlScalarQueryResult<T>First operand.
b
SqlScalarQueryResult<T>Second operand.
Returns
- bool
true when operands are equal, otherwise false.
operator !=(SqlScalarQueryResult<T>, SqlScalarQueryResult<T>)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(SqlScalarQueryResult<T> a, SqlScalarQueryResult<T> b)
Parameters
a
SqlScalarQueryResult<T>First operand.
b
SqlScalarQueryResult<T>Second operand.
Returns
- bool
true when operands are not equal, otherwise false.