PrimusSaaS.Memberships.Dapper
1.0.1
dotnet add package PrimusSaaS.Memberships.Dapper --version 1.0.1
NuGet\Install-Package PrimusSaaS.Memberships.Dapper -Version 1.0.1
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="PrimusSaaS.Memberships.Dapper" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PrimusSaaS.Memberships.Dapper" Version="1.0.1" />
<PackageReference Include="PrimusSaaS.Memberships.Dapper" />
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 PrimusSaaS.Memberships.Dapper --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PrimusSaaS.Memberships.Dapper, 1.0.1"
#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 PrimusSaaS.Memberships.Dapper@1.0.1
#: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=PrimusSaaS.Memberships.Dapper&version=1.0.1
#tool nuget:?package=PrimusSaaS.Memberships.Dapper&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PrimusSaaS.Memberships.Dapper
Dapper + Npgsql storage adapter for PrimusSaaS.Memberships. Implements IMembershipStore, IActiveTenantSelectionStore, and IMembershipInvitationStore using raw SQL against PostgreSQL. No Entity Framework dependency.
Compatible with .NET 8, 9, and 10.
Quick Start
// Program.cs
builder.Services
.AddPrimusMemberships(opts =>
builder.Configuration.GetSection("PrimusMemberships").Bind(opts))
.AddMembershipsDapper(
new NpgsqlMembershipsDbConnectionFactory(
builder.Configuration.GetConnectionString("MembershipsDb")!));
PostgreSQL Schema
Run this DDL once per database before starting the application:
-- Tenant-user memberships
CREATE TABLE IF NOT EXISTS primus_memberships (
tenant_id TEXT NOT NULL,
user_id TEXT NOT NULL,
email TEXT,
status INT NOT NULL DEFAULT 0,
is_default_tenant BOOL NOT NULL DEFAULT FALSE,
joined_at_utc TIMESTAMPTZ NOT NULL DEFAULT NOW(),
invited_at_utc TIMESTAMPTZ,
activated_at_utc TIMESTAMPTZ,
suspended_at_utc TIMESTAMPTZ,
expires_at_utc TIMESTAMPTZ,
source TEXT,
roles JSONB,
metadata JSONB,
PRIMARY KEY (tenant_id, user_id)
);
CREATE INDEX IF NOT EXISTS idx_primus_memberships_user ON primus_memberships (user_id);
CREATE INDEX IF NOT EXISTS idx_primus_memberships_status ON primus_memberships (tenant_id, status);
-- Active tenant selection (user's last-known active tenant)
CREATE TABLE IF NOT EXISTS primus_active_tenant_selections (
user_id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
selected_at_utc TIMESTAMPTZ NOT NULL DEFAULT NOW(),
source TEXT NOT NULL DEFAULT 'manual'
);
-- Membership invitations
CREATE TABLE IF NOT EXISTS primus_membership_invitations (
invitation_id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
email TEXT NOT NULL,
invited_by_user_id TEXT NOT NULL,
status INT NOT NULL DEFAULT 0,
created_at_utc TIMESTAMPTZ NOT NULL DEFAULT NOW(),
expires_at_utc TIMESTAMPTZ NOT NULL,
accepted_at_utc TIMESTAMPTZ,
revoked_at_utc TIMESTAMPTZ,
acceptance_attempts INT NOT NULL DEFAULT 0,
requested_roles JSONB,
metadata JSONB
);
CREATE INDEX IF NOT EXISTS idx_primus_invitations_tenant_email
ON primus_membership_invitations (tenant_id, email, status);
MembershipStatus Values
| Value | Int |
|---|---|
| Pending | 0 |
| Active | 1 |
| Suspended | 2 |
| Revoked | 3 |
| Expired | 4 |
InvitationStatus Values
| Value | Int |
|---|---|
| Pending | 0 |
| Accepted | 1 |
| Revoked | 2 |
| Expired | 3 |
Row-Level Security (optional)
ALTER TABLE primus_memberships ENABLE ROW LEVEL SECURITY;
CREATE POLICY membership_rls ON primus_memberships
AS PERMISSIVE FOR ALL
USING (tenant_id = current_setting('app.current_tenant', TRUE));
Then use ITenantRlsInitializer (from PrimusSaaS.MultiTenancy.Dapper) to set the variable.
Environment Variables
ConnectionStrings__MembershipsDb=Host=localhost;Database=primus;Username=app;Password=secret;
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Dapper (>= 2.1.35)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Npgsql (>= 10.0.2)
- PrimusSaaS.Memberships (>= 0.2.0)
-
net8.0
- Dapper (>= 2.1.35)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Npgsql (>= 10.0.2)
- PrimusSaaS.Memberships (>= 0.2.0)
-
net9.0
- Dapper (>= 2.1.35)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Npgsql (>= 10.0.2)
- PrimusSaaS.Memberships (>= 0.2.0)
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.1 | 141 | 4/19/2026 |
v1.0.0: Initial release — Dapper + Npgsql adapter for Memberships.