Table of Contents

Class VersionExtensions

Namespace
FishMMO.Database.Data
Assembly
FishMMO-DB.dll

Extension methods for working with versioned DTOs. These helpers ensure callers explicitly increment versions before persist operations. Because DTOs are immutable structs, these methods return new instances with incremented versions.

public static class VersionExtensions
Inheritance
VersionExtensions
Inherited Members

Methods

WithIncrementedVersion<T>(T)

Returns a new DTO with an incremented version for fluent chaining. Call this immediately before passing the DTO to a persist method.

public static T WithIncrementedVersion<T>(this T data) where T : struct, IVersioned<T>

Parameters

data T

The versioned DTO to increment.

Returns

T

A new DTO instance with an incremented version.

Type Parameters

T

A struct type implementing IVersioned<T>.

Examples

await factionService.PersistAsync(new[] { factionData.WithIncrementedVersion() }, ct);

WithIncrementedVersionsToList<T>(IEnumerable<T>)

Returns a new list with all items having incremented versions. More efficient than WithIncrementedVersions<T>(IEnumerable<T>) when you need a list result.

public static List<T> WithIncrementedVersionsToList<T>(this IEnumerable<T> data) where T : struct, IVersioned<T>

Parameters

data IEnumerable<T>

The list of versioned DTOs to increment.

Returns

List<T>

A new list with all items' versions incremented.

Type Parameters

T

A struct type implementing IVersioned<T>.

Examples

await factionService.PersistAsync(factionList.WithIncrementedVersionsToList(), ct);

WithIncrementedVersions<T>(IEnumerable<T>)

Returns new DTOs with incremented versions for all items in a collection. Call this immediately before passing the collection to a persist method.

public static IEnumerable<T> WithIncrementedVersions<T>(this IEnumerable<T> data) where T : struct, IVersioned<T>

Parameters

data IEnumerable<T>

The collection of versioned DTOs to increment.

Returns

IEnumerable<T>

An enumerable of new DTO instances with incremented versions.

Type Parameters

T

A struct type implementing IVersioned<T>.

Examples

await factionService.PersistAsync(factions.WithIncrementedVersions().ToList(), ct);