TwoFiveThree.Repository.SqlBase 2.0.3

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

TwoFiveThree.Repository.SqlBase

Shared SQL infrastructure for the TwoFiveThree repository library. Provides RepositoryBase, SqlBuilder, and ExpressionTranslator — the building blocks for SQL-based providers such as TwoFiveThree.Repository.Psql and TwoFiveThree.Repository.MySql.

This package is intended for provider authors, not application consumers. If you are building an application, install a provider package directly instead:

dotnet add package TwoFiveThree.Repository.Psql
# or
dotnet add package TwoFiveThree.Repository.MySql

Packages

Package Description
TwoFiveThree.Repository Core abstractions
TwoFiveThree.Repository.SqlBase SQL infrastructure (this package)
TwoFiveThree.Repository.Psql PostgreSQL provider
TwoFiveThree.Repository.MySql MySQL provider
TwoFiveThree.Repository.MvBase MultiValue infrastructure
TwoFiveThree.Repository.Analysers Roslyn analysers

Requirements

  • .NET Standard 2.0+ (.NET Framework 4.6.1, .NET Core, .NET 5+)
  • TwoFiveThree.Repository
  • Dapper 2.x

Installation

dotnet add package TwoFiveThree.Repository.SqlBase

Writing a SQL Provider

Reference this package and extend RepositoryBase. The only method you must implement is CreateConnection() — return the DbConnection for your database driver:

internal sealed class MyDatabaseRepository : RepositoryBase
{
    private readonly string _connectionString;

    public MyDatabaseRepository(string connectionString) =>
        _connectionString = connectionString;

    protected override DbConnection CreateConnection() =>
        new MyDatabaseConnection(_connectionString);
}

All query execution, SQL building, expression translation, audit methods, and navigation property mapping are inherited automatically.

Register via RepositoryOptions.UseProvider:

public static class MyDatabaseRepositoryExtensions
{
    public static RepositoryOptions UseMyDatabase(
        this RepositoryOptions options,
        string connectionString) =>
        options.UseProvider(_ => new MyDatabaseRepository(connectionString));
}

Key Components

RepositoryBase

Abstract base class implementing IRepository. Inherit this to build a SQL provider. Provides:

  • DeleteAsync<T> — DELETE by primary key`
  • ExecuteAsync — Execute arbitrary SQL with parameters`
  • ExecuteScalarAsync<T> — Execute arbitrary SQL with parameters and return a single value`
  • InsertAsync<T> — INSERT
  • InsertWithAuditAsync<T, TAudit> — INSERT with audit record
  • QueryAsync<T> — Execute arbitrary SQL with parameters and return mapped entities`
  • QueryFirstOrDefaultAsync<T> — Execute arbitrary SQL with parameters and return a single mapped entity`
  • SelectAllAsync<T> — SELECT with optional filter, ordering, and LEFT JOIN resolution for navigation properties
  • SelectByIdAsync<T> — SELECT by primary key
  • UpdateAsync<T> — UPDATE by primary key
  • UpdateWithAuditAsync<T, TAudit> — UPDATE with diff-based audit record
  • UpsertAsync<T> — UPSERT by primary key (INSERT or UPDATE)

Abstract members:

protected abstract DbConnection CreateConnection();
protected abstract string GetLastInsertedIdCommand(string autoGeneratedColumnName);
protected abstract string GetUpsertSql(string tableName, List<string> columns, List<string> paramValues, Dictionary<string, object>? primaryKeys, string returning);

SqlBuilder

Internal component that generates parameterised SQL statements from entity metadata. Handles:

  • Column and table name resolution via [Table], [Column], and [PrimaryKey] attributes
  • LEFT JOIN generation for navigation properties decorated with [ForeignKey] or following the {PropertyName}Id convention
  • splitOn parameter generation for Dapper multi-map queries
  • WHERE clause injection from translated expressions
  • ORDER BY clause injection

ExpressionTranslator

Translates a LINQ Expression<Func<T, bool>> into a parameterised SQL WHERE clause. Supports:

Expression SQL
x.Id == 1 t1.id = @p0
x.Id != 1 t1.id <> @p0
x.Age > 18 t1.age > @p0
x.Age >= 18 t1.age >= @p0
x.Age < 65 t1.age < @p0
x.Age <= 65 t1.age <= @p0
x.Name.StartsWith("R") t1.name LIKE @p0 (R%)
x.Name.EndsWith("son") t1.name LIKE @p0 (%son)
x.Name.Contains("ob") t1.name LIKE @p0 (%ob%)
&& AND
\|\| OR
Captured variables Correctly parameterised

Entity Configuration

Entities used with SQL providers must implement IEntity and be decorated with [Table] and [PrimaryKey]. Navigation properties are resolved automatically via the [ForeignKey] attribute or naming convention.

[Table("people")]
[PrimaryKey("id")]
public class Person : IEntity
{
    public int Id { get; set; }
    public string Name { get; set; } = default!;
    public string GenderId { get; set; } = default!;

    // Explicit foreign key
    [ForeignKey(nameof(GenderId))]
    public Gender? Gender { get; set; }
}

[Table("gender")]
[PrimaryKey("id")]
public class Gender : IEntity
{
    public string Id { get; set; } = default!;
    public string Description { get; set; } = default!;
}

Navigation properties without [ForeignKey] follow the convention {PropertyName}Id:

// Convention — no attribute needed, GenderId is resolved automatically
public Gender? Gender { get; set; }
public string GenderId { get; set; } = default!;

Dependencies

Package Version
TwoFiveThree.Repository Same major version
Dapper [2.0.0, 3.0.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on TwoFiveThree.Repository.SqlBase:

Package Downloads
TwoFiveThree.Repository.Psql

PostgreSql Implementation of the TwoFiveThree repository

TwoFiveThree.Repository.MySql

MySql Implementation of the TwoFiveThree repository

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.3 74 6/1/2026
2.0.2 75 5/29/2026