logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Struct StructuredValue

    A single typed value stored in a StructuredRecord field: a null, a string, a 64-bit integer, a double, or a boolean. Immutable value object that supports equality comparison and a kind-aware total order via Compare(StructuredValue, StructuredValue).

    Implements
    IEquatable<StructuredValue>
    Inherited Members
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    Namespace: Serenity.Persistence.Domain.ValueObjects
    Assembly: Serenity.Global.Domain.dll
    Syntax
    public readonly struct StructuredValue : IEquatable<StructuredValue>

    Fields

    Kind

    Which primitive this value holds.

    Declaration
    public readonly StructuredValueKind Kind
    Field Value
    Type Description
    StructuredValueKind

    Null

    The single, shared representation of the JSON/SQL null value.

    Declaration
    public static readonly StructuredValue Null
    Field Value
    Type Description
    StructuredValue

    Methods

    AsBool()

    Gets the boolean value.

    Declaration
    public bool AsBool()
    Returns
    Type Description
    bool
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when this value is not a bool.

    AsDouble()

    Gets the double value.

    Declaration
    public double AsDouble()
    Returns
    Type Description
    double
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when this value is not a double.

    AsLong()

    Gets the 64-bit integer value.

    Declaration
    public long AsLong()
    Returns
    Type Description
    long
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when this value is not a long.

    AsString()

    Gets the string value, or null when this value is Null.

    Declaration
    public string AsString()
    Returns
    Type Description
    string
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when this value is neither a string nor null.

    Compare(StructuredValue, StructuredValue)

    Compares two values in a kind-aware total order. Null orders BEFORE any non-null value (and two nulls are equal), so nullable fields still sort deterministically. Comparing two NON-null values of different kinds throws ArgumentException — a field must hold one consistent kind, and a silent cross-kind ordering would let relational backends (which compare by column type) diverge from the in-memory engine. Doubles compare by exact value equality (no epsilon tolerance); strings compare via ordinal comparison.

    Declaration
    public static int Compare(StructuredValue left, StructuredValue right)
    Parameters
    Type Name Description
    StructuredValue left
    StructuredValue right
    Returns
    Type Description
    int
    Exceptions
    Type Condition
    ArgumentException

    Thrown when both values are non-null and their kinds differ.

    Equals(StructuredValue)

    Declaration
    public bool Equals(StructuredValue other)
    Parameters
    Type Name Description
    StructuredValue other
    Returns
    Type Description
    bool

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    Of(bool)

    Creates a StructuredValue holding a boolean.

    Declaration
    public static StructuredValue Of(bool value)
    Parameters
    Type Name Description
    bool value
    Returns
    Type Description
    StructuredValue

    Of(double)

    Creates a StructuredValue holding a double.

    Declaration
    public static StructuredValue Of(double value)
    Parameters
    Type Name Description
    double value
    Returns
    Type Description
    StructuredValue

    Of(long)

    Creates a StructuredValue holding a 64-bit integer.

    Declaration
    public static StructuredValue Of(long value)
    Parameters
    Type Name Description
    long value
    Returns
    Type Description
    StructuredValue

    Of(string)

    Creates a StructuredValue holding a string, or Null when value is null.

    Declaration
    public static StructuredValue Of(string value)
    Parameters
    Type Name Description
    string value
    Returns
    Type Description
    StructuredValue

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Operators

    operator ==(StructuredValue, StructuredValue)

    Declaration
    public static bool operator ==(StructuredValue left, StructuredValue right)
    Parameters
    Type Name Description
    StructuredValue left
    StructuredValue right
    Returns
    Type Description
    bool

    operator !=(StructuredValue, StructuredValue)

    Declaration
    public static bool operator !=(StructuredValue left, StructuredValue right)
    Parameters
    Type Name Description
    StructuredValue left
    StructuredValue right
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>
    In this article
    © 2026 Serenity. All Rights Reserved