logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class GameSaveRecordMapping

    Maps between SaveSlotId/SaveDocument and the generic StructuredRecord shape, and builds the field-name-driven schema and scope filters StructuredStoreGameSaveAdapter needs. The single place that knows the game-save table's column names.

    Inheritance
    object
    GameSaveRecordMapping
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameSave.Infrastructure
    Assembly: Serenity.GameSave.Infrastructure.dll
    Syntax
    public static class GameSaveRecordMapping
    Remarks

    Every save slot is stored as its own row within a single shared partition (analogous to how Serenity.Leaderboard.Infrastructure.LeaderboardRecordMapping shares one partition per board across every player row): the key-value backend's mandatory partition field is PartitionField, fixed to GlobalPartitionValue for every row, while SlotIndexField is an ordinary field distinguishing rows within that partition. This is a deliberate departure from a "partition per slot" scheme: it is the only shape that lets QuerySummariesAsync(CancellationToken) list every occupied slot in one query — a key-value-backed IStructuredStore can only answer queries scoped to a single partition (see KeyValueStructuredStore's remarks), so partitioning by slot index would make a cross-slot summary listing impossible on that backend family.

    Fields

    CompletionPercentField

    Field name storing CompletionPercent.

    Declaration
    public const string CompletionPercentField = "completion_percent"
    Field Value
    Type Description
    string

    DefaultTableName

    The default table or collection name used when the settings leave it blank.

    Declaration
    public const string DefaultTableName = "serenity_game_save"
    Field Value
    Type Description
    string

    GlobalPartitionValue

    The single partition value every game-save row is stored under.

    Declaration
    public const string GlobalPartitionValue = "global"
    Field Value
    Type Description
    string

    KeyFieldsPartitionAndSlot

    The PartitionField/SlotIndexField key used to identify a slot's row for upsert-if-newer.

    Declaration
    public static readonly IReadOnlyList<string> KeyFieldsPartitionAndSlot
    Field Value
    Type Description
    IReadOnlyList<string>

    LabelField

    Field name storing Label.

    Declaration
    public const string LabelField = "label"
    Field Value
    Type Description
    string

    PartitionField

    Field name partitioning every game-save row (see the type remarks for why this is a single shared value rather than the slot index).

    Declaration
    public const string PartitionField = "partition"
    Field Value
    Type Description
    string

    PayloadField

    Field name storing every registered section's serialized JSON, keyed by section key.

    Declaration
    public const string PayloadField = "payload"
    Field Value
    Type Description
    string

    PlaytimeSecondsField

    Field name storing PlaytimeSeconds.

    Declaration
    public const string PlaytimeSecondsField = "playtime_seconds"
    Field Value
    Type Description
    string

    SavedAtTicksField

    Field name storing SavedAtUtcTicks.

    Declaration
    public const string SavedAtTicksField = "saved_at_ticks"
    Field Value
    Type Description
    string

    SlotIndexField

    Field name storing the zero-based slot index a row belongs to.

    Declaration
    public const string SlotIndexField = "slot_index"
    Field Value
    Type Description
    string

    Methods

    BuildPartitionScopeFilters()

    Builds the partition = "global" scope filter shared by every cross-slot operation (e.g. listing summaries).

    Declaration
    public static IReadOnlyList<FieldFilter> BuildPartitionScopeFilters()
    Returns
    Type Description
    IReadOnlyList<FieldFilter>

    BuildSchema(StoreTable)

    Builds the game-save table schema: fields and the partition/slot index.

    Declaration
    public static StructuredTableSchema BuildSchema(StoreTable table)
    Parameters
    Type Name Description
    StoreTable table
    Returns
    Type Description
    StructuredTableSchema

    BuildSlotScopeFilters(SaveSlotId)

    Builds the partition = "global" AND slot_index = slotId scope filter shared by every single-slot operation.

    Declaration
    public static IReadOnlyList<FieldFilter> BuildSlotScopeFilters(SaveSlotId slotId)
    Parameters
    Type Name Description
    SaveSlotId slotId
    Returns
    Type Description
    IReadOnlyList<FieldFilter>

    ToDocument(StructuredRecord)

    Maps a StructuredRecord back to a full SaveDocument, decoding every section payload.

    Declaration
    public static SaveDocument ToDocument(StructuredRecord record)
    Parameters
    Type Name Description
    StructuredRecord record
    Returns
    Type Description
    SaveDocument

    ToRecord(SaveSlotId, SaveDocument)

    Maps a slot id and its document to their StructuredRecord field representation.

    Declaration
    public static StructuredRecord ToRecord(SaveSlotId slotId, SaveDocument document)
    Parameters
    Type Name Description
    SaveSlotId slotId
    SaveDocument document
    Returns
    Type Description
    StructuredRecord

    ToSummary(StructuredRecord)

    Maps a StructuredRecord to a metadata-only SaveSlotSummary, WITHOUT decoding the section payload.

    Declaration
    public static SaveSlotSummary ToSummary(StructuredRecord record)
    Parameters
    Type Name Description
    StructuredRecord record
    Returns
    Type Description
    SaveSlotSummary
    In this article
    © 2026 Serenity. All Rights Reserved