SoftwareDriven.Persistence 3.1.0

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

SoftwareDriven.Persistence

A .NET persistence abstraction library providing a unified interface for different data storage backends. Targets net10.0.

Installation

dotnet add package SoftwareDriven.Persistence

Core Interfaces

Interface Purpose
IPersistenceModel Base model interface requiring string? Id
IBasicPersistenceProvider<T> CRUD operations, expression-based querying, pagination
IPersistenceProvider<T> Extended: nested collection projections, element match, file storage
IDatabaseManager Provider factory and table name registry

Built-in: FileSystem Provider

The core package includes a JSON file-based provider for simple scenarios.

services.AddSingleton(new JsonSerializerOptions());
services.AddSingleton<FileSystemManager>();
services.AddSingleton<FileSystemDataProvider<MyModel>>();

Provider Packages

Package Backend
SoftwareDriven.Persistence.MongoDb MongoDB
SoftwareDriven.Persistence.Cassandra Apache Cassandra
SoftwareDriven.Persistence.EF.SQLite Entity Framework Core / SQLite
SoftwareDriven.Persistence.IndexedDb Browser IndexedDB (Blazor)

Usage

All providers implement the same interfaces, allowing backend-agnostic code:

public class MyService
{
    private readonly IBasicPersistenceProvider<MyModel> provider;

    public MyService(IBasicPersistenceProvider<MyModel> provider)
    {
        this.provider = provider;
    }

    public async Task Example()
    {
        // Create
        await provider.CreateOrUpdate(new MyModel { Title = "Hello" });

        // Query with expressions
        var results = await provider.FindByExpression(x => x.Title == "Hello");

        // Paginate
        var page = await provider.GetAll(new PaginationOptions<MyModel>
        {
            PageSize = 10,
            PageNumber = 0
        });
    }
}

Maintenance

Deleting entries does not necessarily return their storage to the file system. IDatabaseManager therefore offers maintenance on the database as a whole, independent of a single entity:

if (!databaseManager.SupportsMaintenance)
    return;

var statistics = await databaseManager.GetStatistics();
// statistics.TotalBytes        - what the database occupies
// statistics.ReclaimableBytes  - occupied without being used
// statistics.IsAvailable       - whether the figures could be determined

var result = await databaseManager.Compact();
// result.Success, result.BytesBefore, result.BytesAfter, result.Error

Query SupportsMaintenance instead of switching on DatabaseType. Backends without a maintenance concept report false, unavailable statistics and a CompactResult with Success = false and an explanatory Error.

Backend SupportsMaintenance Operation
EF.SQLite true VACUUM plus PRAGMA wal_checkpoint(TRUNCATE)
MongoDb true (when connected) compact per collection, figures from dbStats
Cassandra false compaction is a matter of the server and nodetool
FileSystem false deleted entries vanish with their file
IndexedDb false the browser manages the storage itself

Models

Inherit from PersistenceModelBase or implement IPersistenceModel:

public class MyModel : PersistenceModelBase
{
    public string Title { get; set; } = "";
    public bool IsActive { get; set; }
}

License

MIT

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

Showing the top 5 NuGet packages that depend on SoftwareDriven.Persistence:

Package Downloads
SoftwareDriven.Persistence.MongoDb

SoftwareDriven.Persistence.MongoDb is a library with a persistence layer for MongoDb building on top of SoftwareDriven.Persistence.

SoftwareDriven.Persistence.Cassandra

SoftwareDriven.Persistence.Cassandra is a library with a persistence layer for Apache Cassandra building on top of SoftwareDriven.Persistence. Includes DataStax C# Driver for Apache Cassandra v3.19.1 with modifications.

SoftwareDriven.Persistence.EF.SQLite

SoftwareDriven.Persistence.EF.SQLite is a library with a persistence layer for EntityFramework SQLite building on top of SoftwareDriven.Persistence.

SoftwareDriven.Persistence.IndexedDb

SoftwareDriven.Persistence.IndexedDb is a library with a persistence layer for browser IndexedDB building on top of SoftwareDriven.Persistence.

SoftwareDriven.Persistence.S3

SoftwareDriven.Persistence.S3 is a library with a persistence layer for S3-compatible object storage building on top of SoftwareDriven.Persistence.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 37 8/25/2026
3.0.5 460 4/2/2026
3.0.4 242 2/12/2026
3.0.3 347 2/11/2026
3.0.2 141 2/11/2026
3.0.1 149 2/11/2026
3.0.0 232 2/1/2026
2.12.0 227 1/8/2026
2.9.1 529 4/24/2025
2.9.0 957 11/30/2024
2.8.2 298 11/18/2024
2.8.1 660 7/19/2024
2.8.0 443 7/7/2024
2.7.3 249 11/18/2024
2.7.2 277 6/30/2024
2.7.0 1,150 11/27/2023
2.6.1 1,063 7/25/2023
2.6.0 843 7/23/2023
2.5.3 848 4/21/2023
Loading failed