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

This is a prerelease version of FractalDataWorks.Commands.Data.
dotnet add package FractalDataWorks.Commands.Data --version 0.9.0-alpha.1011.ged0a6c6e98
                    
NuGet\Install-Package FractalDataWorks.Commands.Data -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" 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" Version="0.9.0-alpha.1011.ged0a6c6e98" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.Commands.Data" />
                    
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 --version 0.9.0-alpha.1011.ged0a6c6e98
                    
#r "nuget: FractalDataWorks.Commands.Data, 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@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&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.Commands.Data&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
                    
Install as a Cake Tool

FractalDataWorks DataCommands

Universal data command system that provides a single, type-safe API for working with data across any backend - SQL databases, REST APIs, file systems, GraphQL endpoints, and more.

๐Ÿš€ Quick Start

// Query customers
var command = new QueryCommand<Customer>("Customers")
{
    Filter = new FilterExpression
    {
        Conditions =
        [
            new FilterCondition
            {
                PropertyName = nameof(Customer.IsActive),
                Operator = FilterOperators.Equal,
                Value = true
            }
        ]
    }
};

var result = await connection.ExecuteAsync(command);

๐Ÿ“š Documentation

User Documentation

Design Documentation

โœจ Key Features

โœ… Universal API - One command works with SQL, REST, Files, GraphQL โœ… Type-Safe - Full compile-time type checking with generics โœ… Zero Boxing - No object casting or performance overhead โœ… Extensible - Add commands and translators without changing existing code โœ… Railway-Oriented - Explicit error handling with IGenericResult<T> โœ… No Switch Statements - Clean dispatch via TypeCollections and visitor pattern

๐Ÿ—๏ธ Architecture

Application Code
    โ†“
DataCommands (Universal)
    โ†“
Translators (Backend-Specific)
    โ†“
Connections (Protocol)
    โ†“
Data Sources

Projects

FractalDataWorks.Commands.Data.Abstractions/  โ† Interfaces and base classes
FractalDataWorks.Commands.Data/               โ† Concrete implementations
FractalDataWorks.Commands.Data.Translators/   โ† Translator implementations (TBD)

๐ŸŽฏ Core Concepts

Commands

Operations on data:

  • QueryCommand<T> - Retrieve data
  • InsertCommand<T> - Add new data
  • UpdateCommand<T> - Modify data
  • DeleteCommand - Remove data

Expressions

Query logic:

  • FilterExpression - WHERE conditions
  • ProjectionExpression - SELECT fields
  • OrderingExpression - ORDER BY
  • PagingExpression - SKIP/TAKE

Translators

Backend conversion:

  • SqlTranslator โ†’ SQL statements
  • RestTranslator โ†’ HTTP + OData
  • FileTranslator โ†’ File I/O

Operators

TypeCollection of filter operators:

  • FilterOperators.Equal โ†’ = / eq
  • FilterOperators.Contains โ†’ LIKE '%value%' / contains
  • FilterOperators.GreaterThan โ†’ > / gt
  • And 9 more...

๐Ÿ“ Example Usage

Query with Multiple Conditions

var command = new QueryCommand<Customer>("Customers")
{
    Filter = new FilterExpression
    {
        Logic = LogicalOperator.And,
        Conditions =
        [
            new FilterCondition
            {
                PropertyName = nameof(Customer.IsActive),
                Operator = FilterOperators.Equal,
                Value = true
            },
            new FilterCondition
            {
                PropertyName = nameof(Customer.TotalSpent),
                Operator = FilterOperators.GreaterThanOrEqual,
                Value = 10000
            }
        ]
    },
    Paging = new PagingExpression { Skip = 0, Take = 50 }
};

Multi-Backend Support

// Same command works with any backend!
var sqlResult = await sqlConnection.ExecuteAsync(command);      // โ†’ SQL
var restResult = await httpConnection.ExecuteAsync(command);    // โ†’ REST API
var fileResult = await fileConnection.ExecuteAsync(command);    // โ†’ JSON file

Insert with Type Safety

var customer = new Customer
{
    Name = "John Doe",
    Email = "john@example.com",
    IsActive = true
};

var command = new InsertCommand<Customer>("Customers", customer);
var result = await connection.ExecuteAsync(command);

if (result.IsSuccess)
{
    var newId = result.Value; // Type-safe! No casting needed
    Console.WriteLine($"Created customer with ID: {newId}");
}

๐Ÿ”ง Building Custom Commands

[TypeOption(typeof(DataCommands), "MyCustomCommand")]
public sealed class MyCustomCommand<T> : DataCommandBase<T>
{
    public MyCustomCommand(string containerName)
        : base(
            id: 10,
            name: "MyCustomCommand",
            containerName,
            DataCommandCategory.Query)
    {
    }

    // Add command-specific properties
    public string? CustomProperty { get; init; }
}

๐Ÿงช Testing

[Fact]
public async Task ExecuteAsync_WithFilter_ReturnsFilteredResults()
{
    // Arrange
    var mockConnection = new Mock<IDataConnection>();
    var command = new QueryCommand<Customer>("Customers")
    {
        Filter = CustomerFilters.Active()
    };

    // Act
    var result = await mockConnection.Object.ExecuteAsync(command);

    // Assert
    result.IsSuccess.Should().BeTrue();
}

๐ŸŽ“ Learning Path

  1. Start Here: Overview - Understand the architecture
  2. Build Commands: Developer Guide - Create your first command
  3. Build Translators: Translator Guide - Support new backends
  4. See Examples: Examples - Real-world patterns

๐Ÿ†š Comparisons

vs. Entity Framework Core

  • โœ… Works with non-SQL backends (REST, Files, GraphQL)
  • โœ… Easier testing (mock connections, not databases)
  • โš ๏ธ No change tracking or migrations

vs. Dapper

  • โœ… Type-safe query building (no string SQL)
  • โœ… Works with non-SQL backends
  • โœ… Protected from SQL injection by design

vs. Repository Pattern

  • โœ… No code duplication (shared commands)
  • โœ… Easy to swap backends
  • โœ… Consistent API across data sources

๐Ÿ“ฆ Current Status

  • โœ… Architecture: Complete
  • โœ… Commands.Data.Abstractions: Implemented
  • โœ… Commands.Data: Implemented (4 commands, 12 operators)
  • โœ… Documentation: Complete
  • โณ Translators: Not yet started (see guides for implementation)
  • โณ Samples: Planned

๐Ÿค Contributing

See design docs in docs/design/datacommands/ for architectural decisions and patterns to follow.

Key Conventions

  • โœ… Use TypeCollections instead of enums
  • โœ… Use Railway-Oriented Programming (IGenericResult)
  • โœ… Use visitor pattern (no switch statements)
  • โœ… Properties set in constructors (for TypeCollection compatibility)
  • โœ… Full XML documentation

๐Ÿ“„ License

Part of the FractalDataWorks Developer Kit.


  • API Reference: src/FractalDataWorks.Commands.Data.Abstractions/
  • Implementation: src/FractalDataWorks.Commands.Data/
  • Design History: docs/design/datacommands/
  • Samples: samples/DataCommands/ (coming soon)

Version: 1.0.0 Last Updated: October 2024 Branch: feature/datacommands-architecture

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 (6)

Showing the top 5 NuGet packages that depend on FractalDataWorks.Commands.Data:

Package Downloads
FractalDataWorks.Data.Rest

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Commands.Data.Extensions

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Services.Data

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Data.Sql

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Data.MsSql

Development tools and utilities for the FractalDataWorks ecosystem. Build:

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0-alpha.1011.ged0a6c6e98 42 11/18/2025
0.9.0-alpha.1010.gecd88aac50 39 11/18/2025
0.9.0-alpha.1009.g7f6817e985 36 11/18/2025
0.9.0-alpha.1006.gf287016c0c 48 11/18/2025
0.8.0-alpha.1011 39 11/18/2025
0.7.0-alpha.1022 135 11/3/2025
0.7.0-alpha.1021 138 11/3/2025
0.7.0-alpha.1008 106 11/2/2025
0.7.0-alpha.1006 136 10/30/2025
0.7.0-alpha.1005 129 10/30/2025
0.7.0-alpha.1004 131 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 126 10/28/2025
0.6.0-alpha.1004 128 10/28/2025
0.6.0-alpha.1002 125 10/28/2025