MarcusMedina.Fluent.Data.Sql 1.0.2

dotnet add package MarcusMedina.Fluent.Data.Sql --version 1.0.2
                    
NuGet\Install-Package MarcusMedina.Fluent.Data.Sql -Version 1.0.2
                    
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="MarcusMedina.Fluent.Data.Sql" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarcusMedina.Fluent.Data.Sql" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="MarcusMedina.Fluent.Data.Sql" />
                    
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 MarcusMedina.Fluent.Data.Sql --version 1.0.2
                    
#r "nuget: MarcusMedina.Fluent.Data.Sql, 1.0.2"
                    
#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 MarcusMedina.Fluent.Data.Sql@1.0.2
                    
#: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=MarcusMedina.Fluent.Data.Sql&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=MarcusMedina.Fluent.Data.Sql&version=1.0.2
                    
Install as a Cake Tool

MarcusMedina.Fluent.Data.Sql

NuGet NuGet Downloads C# .NET License: MIT Open Source Build Signed Wiki

Fluent SQL query builder for .NET 10+ — generate parameterized SQL strings without a database connection.

Build SELECT, INSERT, UPDATE, DELETE statements fluently with automatic escaping per database dialect.

This came from watching my students struggle with writing SQL by hand. I designed this to help them along the way — though, cheekily, before the course ended they still had to wrestle with raw query strings anyway.

In this case, I wanted a builder that produces the exact same parameterised SQL a student would eventually have to write themselves, so it doubles as a way to check your own work.


Features

  • Multi-dialect — PostgreSQL, MySQL, SQLite, SQL Server (configurable via DatabaseType)
  • SELECT — Columns, WHERE, ORDER BY, LIMIT, OFFSET, JOIN
  • INSERT — Single and multi-row
  • UPDATE — With WHERE, JOIN support
  • DELETE — With WHERE, JOIN support
  • Automatic escaping — Quoted identifiers per dialect (`, ", [])
  • Composable WHEREAnd(), Or(), nested conditions
  • Zero dependencies — Pure .NET, no external packages

Installation

dotnet add package MarcusMedina.Fluent.Data.Sql

Requirements: .NET 10.0+, C# 14.0+


Quick Start

using MarcusMedina.Fluent.Data.Sql;

// SELECT
var sql = new Sql(DatabaseType.PostgreSQL)
    .Table("users")
    .Select("id", "name", "email")
    .Where("active = 1")
    .OrderBy("name")
    .Build();

// => SELECT id, name, email FROM users WHERE active = 1 ORDER BY name ASC

// INSERT
var insert = new Sql(DatabaseType.MySQL)
    .Table("users")
    .Insert(new { name = "Alice", email = "alice@example.com" })
    .Build();

// => INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com')

// UPDATE
var update = new Sql(DatabaseType.SQLite)
    .Table("users")
    .Set("name", "Bob")
    .Where("id = 42")
    .Build();

// => UPDATE users SET name = 'Bob' WHERE id = 42

// DELETE
var delete = new Sql(DatabaseType.SqlServer)
    .Table("users")
    .Where("id = 42")
    .Build();

// => DELETE FROM users WHERE id = 42

API Overview

Method Description
Sql(dialect) Create builder with database dialect
Table(name) Set target table
Select(columns) Set SELECT columns
Insert(values) Build INSERT with object/ anonymous type
Set(column, value) Add SET clause for UPDATE
Where(condition) Add WHERE condition
And() / Or() Chain conditions
OrderBy(column, asc) Add ORDER BY
Limit(n) Add LIMIT
Offset(n) Add OFFSET
Join(table, on, type) Add JOIN (INNER, LEFT, RIGHT)
Build() Generate final SQL string

Database Dialects

Dialect Identifier Quotes LIMIT/OFFSET
PostgreSQL "..." LIMIT n OFFSET n
MySQL `...` LIMIT n OFFSET n
SQLite "..." LIMIT n OFFSET n
SQL Server [...] OFFSET n ROWS FETCH NEXT n ROWS ONLY

Testing

dotnet test --configuration Release

Tests: 65 passed — covering all dialects, query types, edge cases, and escaping.


License

MIT — see LICENSE for details.


Built with Human + AI Collaboration

This library was written by Marcus Medina together with Claude Code (Anthropic) — not through "vibe coding" where you just describe and accept, but through genuine collaboration: planning together, reviewing each other's decisions, pushing back when something felt wrong, and iterating until the result felt right.

The goal was always to write code worth reading and code worth using — the kind a student can open, understand, and learn from, and the kind any programmer can drop into real, professional work without wanting to rewrite it from scratch. AI was a partner in that process, not a shortcut around it.

If you're curious about this way of working, the source code and git history are open. Every decision has a reason behind it.

Made for Curious Minds

This library was built with students in mind — not as a black box to copy and paste, but as a real-world example of how clean, purposeful code is written and shared. At the same time, it's built to be genuinely useful in professional projects too — for any developer who's tired of writing the same code over and over.

Whether you're discovering C# for the first time, need a reliable helper for your school project, want a dependable building block for production work, or are simply trying to fall in love with writing code — you're exactly who this was made for.

The source is open. Read it, fork it, break it, improve it. That's the whole point.


Package Integrity

All releases are signed with cosign (Sigstore keyless signing).

To verify a downloaded package, download both the .nupkg and its .sigstore.json bundle from the GitHub Release, then run:

cosign verify-blob <package.nupkg> \
  --bundle <package.nupkg.sigstore.json> \
  --certificate-identity-regexp "https://github.com/MarcusMedinaPro/.*/release.yml" \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Expected output: Verified OK

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.
  • net10.0

    • No dependencies.

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
1.0.2 127 7/20/2026
1.0.1 128 7/3/2026
1.0.0 128 6/30/2026