Toggly.FeatureManagement.Storage.Dapper
3.2.1
See the version list below for details.
dotnet add package Toggly.FeatureManagement.Storage.Dapper --version 3.2.1
NuGet\Install-Package Toggly.FeatureManagement.Storage.Dapper -Version 3.2.1
<PackageReference Include="Toggly.FeatureManagement.Storage.Dapper" Version="3.2.1" />
<PackageVersion Include="Toggly.FeatureManagement.Storage.Dapper" Version="3.2.1" />
<PackageReference Include="Toggly.FeatureManagement.Storage.Dapper" />
paket add Toggly.FeatureManagement.Storage.Dapper --version 3.2.1
#r "nuget: Toggly.FeatureManagement.Storage.Dapper, 3.2.1"
#:package Toggly.FeatureManagement.Storage.Dapper@3.2.1
#addin nuget:?package=Toggly.FeatureManagement.Storage.Dapper&version=3.2.1
#tool nuget:?package=Toggly.FeatureManagement.Storage.Dapper&version=3.2.1
Toggly Dapper Snapshot Provider
Lightweight, high-performance Dapper-based snapshot provider for Toggly Feature Management. Stores feature flag snapshots in SQL databases using raw SQL queries for optimal performance.
Installation
dotnet add package Toggly.FeatureManagement.Storage.Dapper
You'll also need to install the appropriate ADO.NET provider for your database:
# SQL Server
dotnet add package Microsoft.Data.SqlClient
# PostgreSQL
dotnet add package Npgsql
# MySQL
dotnet add package MySqlConnector
# SQLite
dotnet add package Microsoft.Data.Sqlite
Usage
SQL Server
using Toggly.FeatureManagement.Storage.Dapper.Configuration;
using Microsoft.Data.SqlClient;
services.AddTogglyDapperSnapshotProvider(
() => new SqlConnection(Configuration.GetConnectionString("DefaultConnection")),
options => options.Provider = DatabaseProvider.SqlServer
);
// Then configure Toggly as usual
services.AddTogglyFeatureManagement(options => {
options.AppKey = "your-app-key";
options.Environment = "production";
});
PostgreSQL
using Npgsql;
services.AddTogglyDapperSnapshotProvider(
() => new NpgsqlConnection(Configuration.GetConnectionString("PostgresConnection")),
options => options.Provider = DatabaseProvider.PostgreSql
);
MySQL
using MySqlConnector;
services.AddTogglyDapperSnapshotProvider(
() => new MySqlConnection(Configuration.GetConnectionString("MySqlConnection")),
options => options.Provider = DatabaseProvider.MySql
);
SQLite
using Microsoft.Data.Sqlite;
services.AddTogglyDapperSnapshotProvider(
() => new SqliteConnection("Data Source=toggly.db"),
options => options.Provider = DatabaseProvider.Sqlite
);
With Custom Settings
services.AddTogglyDapperSnapshotProvider(
() => new SqlConnection(connectionString),
options => {
options.Provider = DatabaseProvider.SqlServer;
options.TableName = "MyFeatureSnapshots"; // Default: "TogglySnapshots"
options.DocumentName = "my_features"; // Default: "toggly_features"
options.JwkDocumentName = "my_jwks"; // Default: "toggly_jwks"
options.AutoCreateTable = true; // Default: true
}
);
Using Existing Connection Factory
If you've already registered a connection factory:
// Register connection factory separately
services.AddSingleton<Func<IDbConnection>>(() =>
new SqlConnection(Configuration.GetConnectionString("DefaultConnection"))
);
// Then just add the snapshot provider
services.AddTogglyDapperSnapshotProvider(
options => options.Provider = DatabaseProvider.SqlServer
);
Table Schema
The provider creates a single table (default: TogglySnapshots) with the following schema:
| Column | Type | Description |
|---|---|---|
| Id | VARCHAR(100) | Primary key (document name) |
| Data | TEXT/NVARCHAR(MAX) | JSON serialized snapshot data |
| Signature | VARCHAR(1000) | Signature for signed definitions |
| KeyId | VARCHAR(100) | Key ID for signature verification |
| Timestamp | BIGINT | Unix timestamp of the snapshot |
| UpdatedAt | DATETIME | Last update time |
Manual Table Creation
If you prefer to create the table manually, here are the scripts for each database:
SQL Server
CREATE TABLE [TogglySnapshots] (
[Id] NVARCHAR(100) NOT NULL PRIMARY KEY,
[Data] NVARCHAR(MAX) NOT NULL,
[Signature] NVARCHAR(1000) NULL,
[KeyId] NVARCHAR(100) NULL,
[Timestamp] BIGINT NULL,
[UpdatedAt] DATETIME2 NOT NULL DEFAULT GETUTCDATE()
);
PostgreSQL
CREATE TABLE "TogglySnapshots" (
"Id" VARCHAR(100) NOT NULL PRIMARY KEY,
"Data" TEXT NOT NULL,
"Signature" VARCHAR(1000) NULL,
"KeyId" VARCHAR(100) NULL,
"Timestamp" BIGINT NULL,
"UpdatedAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
MySQL
CREATE TABLE `TogglySnapshots` (
`Id` VARCHAR(100) NOT NULL PRIMARY KEY,
`Data` LONGTEXT NOT NULL,
`Signature` VARCHAR(1000) NULL,
`KeyId` VARCHAR(100) NULL,
`Timestamp` BIGINT NULL,
`UpdatedAt` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
SQLite
CREATE TABLE "TogglySnapshots" (
"Id" TEXT NOT NULL PRIMARY KEY,
"Data" TEXT NOT NULL,
"Signature" TEXT NULL,
"KeyId" TEXT NULL,
"Timestamp" INTEGER NULL,
"UpdatedAt" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| Provider | DatabaseProvider | SqlServer | Database type for SQL dialect |
| TableName | string | "TogglySnapshots" | Name of the snapshots table |
| DocumentName | string | "toggly_features" | ID for the feature snapshot document |
| JwkDocumentName | string | "toggly_jwks" | ID for the JWK snapshot document |
| AutoCreateTable | bool | true | Automatically create table if it doesn't exist |
Supported Databases
| Database | Enum Value | Tested Versions |
|---|---|---|
| SQL Server | DatabaseProvider.SqlServer |
2016+ |
| PostgreSQL | DatabaseProvider.PostgreSql |
12+ |
| MySQL/MariaDB | DatabaseProvider.MySql |
5.7+/10.3+ |
| SQLite | DatabaseProvider.Sqlite |
3.x |
Related Packages
- Toggly.FeatureManagement - Core feature management library
- Toggly.FeatureManagement.Storage.EntityFramework - Entity Framework Core provider
- Toggly.FeatureManagement.Storage.RavenDB - RavenDB provider
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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 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. |
-
net10.0
- Dapper (>= 2.1.35)
- Toggly.FeatureManagement (>= 3.2.1)
-
net6.0
- Dapper (>= 2.1.35)
- Toggly.FeatureManagement (>= 3.2.1)
-
net8.0
- Dapper (>= 2.1.35)
- Toggly.FeatureManagement (>= 3.2.1)
-
net9.0
- Dapper (>= 2.1.35)
- Toggly.FeatureManagement (>= 3.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.