FractalDataWorks.Commands.Data.Extensions 0.9.0-alpha.1011.ged0a6c6e98

This is a prerelease version of FractalDataWorks.Commands.Data.Extensions.
dotnet add package FractalDataWorks.Commands.Data.Extensions --version 0.9.0-alpha.1011.ged0a6c6e98
                    
NuGet\Install-Package FractalDataWorks.Commands.Data.Extensions -Version 0.9.0-alpha.1011.ged0a6c6e98
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FractalDataWorks.Commands.Data.Extensions" Version="0.9.0-alpha.1011.ged0a6c6e98" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FractalDataWorks.Commands.Data.Extensions" Version="0.9.0-alpha.1011.ged0a6c6e98" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.Commands.Data.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FractalDataWorks.Commands.Data.Extensions --version 0.9.0-alpha.1011.ged0a6c6e98
                    
#r "nuget: FractalDataWorks.Commands.Data.Extensions, 0.9.0-alpha.1011.ged0a6c6e98"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FractalDataWorks.Commands.Data.Extensions@0.9.0-alpha.1011.ged0a6c6e98
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FractalDataWorks.Commands.Data.Extensions&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.Commands.Data.Extensions&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
                    
Install as a Cake Tool

FractalDataWorks.Commands.Data.Extensions

Extension methods for data command operations providing fluent APIs for command building, validation, and execution. Enhances Commands.Data with builder patterns and convenience methods.

Overview

This package provides extension methods and fluent APIs that simplify working with data commands. It extends Commands.Data with:

  • Fluent Command Builders: Chain methods to construct complex commands
  • Validation Extensions: Simplified validation workflows
  • Execution Extensions: Convenient command execution patterns
  • Transformation Pipelines: Transform and compose commands
  • Result Mapping: Map command results to different types

Target Frameworks: .NET Standard 2.0, .NET 10.0 Dependencies: FractalDataWorks.Commands.Data, FractalDataWorks.Results

Key Extension Categories

Command Builder Extensions

Fluent APIs for constructing data commands:

var command = dataCommand
    .WithParameter("userId", userId)
    .WithParameter("status", "Active")
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithRetry(maxAttempts: 3)
    .Build();

Validation Extensions

Simplified validation workflows:

var validationResult = command
    .ValidateRequired()
    .ValidateParameters()
    .ValidateSchema(schema)
    .GetResult();

if (validationResult.IsFailure)
{
    // Handle validation errors
}

Execution Extensions

Convenient execution patterns:

// Execute and map result
var users = await dataCommand
    .ExecuteAsync<User>(service, cancellationToken)
    .MapResult(users => users.OrderBy(u => u.Name))
    .ToListAsync();

// Execute with retry
var result = await dataCommand
    .ExecuteWithRetry(service, maxAttempts: 3, cancellationToken);

Usage Patterns

Building Complex Commands

public IGenericCommand BuildUserQuery(int departmentId, string searchTerm)
{
    return new QueryCommand()
        .WithParameter("departmentId", departmentId)
        .WithParameter("searchTerm", $"%{searchTerm}%")
        .WithPaging(page: 1, pageSize: 50)
        .WithSorting("LastName", ascending: true)
        .WithProjection("Id", "FirstName", "LastName", "Email")
        .Build();
}

Validation Pipelines

var result = command
    .ValidateNotNull()
    .ValidateCommandType()
    .ValidatePayload(payload => payload != null)
    .ValidateCustom(cmd => cmd.Timeout > TimeSpan.Zero, "Timeout must be positive")
    .Execute();

if (result.IsSuccess)
{
    await service.Execute(command, cancellationToken);
}

Result Transformation

var userNames = await queryCommand
    .ExecuteAsync<User>(service, cancellationToken)
    .MapSuccess(users => users.Select(u => u.FullName))
    .OnFailure(error => logger.LogError(error))
    .GetValueOr(Array.Empty<string>());

Extension Method Patterns

IGenericCommand Extensions

public static class GenericCommandExtensions
{
    public static IGenericCommand WithParameter(
        this IGenericCommand command,
        string name,
        object value);

    public static IGenericCommand WithTimeout(
        this IGenericCommand command,
        TimeSpan timeout);

    public static Task<IGenericResult<T>> ExecuteAsync<T>(
        this IGenericCommand command,
        IGenericService service,
        CancellationToken cancellationToken = default);

    public static IGenericResult<bool> IsValid(
        this IGenericCommand command);
}

IGenericResult Extensions

public static class GenericResultExtensions
{
    public static IGenericResult<TOut> Map<TIn, TOut>(
        this IGenericResult<TIn> result,
        Func<TIn, TOut> mapper);

    public static IGenericResult<T> OnSuccess<T>(
        this IGenericResult<T> result,
        Action<T> action);

    public static IGenericResult<T> OnFailure<T>(
        this IGenericResult<T> result,
        Action<string> action);

    public static T GetValueOr<T>(
        this IGenericResult<T> result,
        T defaultValue);
}

Best Practices

  1. Use Fluent Builders: Chain methods for readable command construction
  2. Validate Early: Use validation extensions before execution
  3. Handle Failures: Use OnFailure for consistent error handling
  4. Map Results: Transform results inline instead of separate steps
  5. Leverage Defaults: Use GetValueOr for safe default handling

Dependencies

  • FractalDataWorks.Commands.Data: Core command data types
  • FractalDataWorks.Results: Result pattern support
  • FractalDataWorks.Abstractions: Base interfaces

Summary

FractalDataWorks.Commands.Data.Extensions provides fluent APIs and extension methods that make working with data commands more convenient and readable. The builder patterns, validation pipelines, and result transformations enable cleaner, more maintainable command-based code.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0-alpha.1011.ged0a6c6e98 43 11/18/2025
0.9.0-alpha.1010.gecd88aac50 44 11/18/2025
0.9.0-alpha.1009.g7f6817e985 39 11/18/2025
0.9.0-alpha.1006.gf287016c0c 38 11/18/2025
0.8.0-alpha.1011 37 11/18/2025
0.7.0-alpha.1022 130 11/3/2025
0.7.0-alpha.1021 130 11/3/2025
0.7.0-alpha.1008 104 11/2/2025
0.7.0-alpha.1006 131 10/30/2025
0.7.0-alpha.1005 128 10/30/2025
0.7.0-alpha.1004 128 10/30/2025
0.7.0-alpha.1001 132 10/29/2025
0.6.0-alpha.1006 133 10/29/2025
0.6.0-alpha.1005 130 10/28/2025
0.6.0-alpha.1004 131 10/28/2025