HatTrick.MemDb 6.2.2

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

HatTrick.MemDb

NuGet License: Apache-2.0

An embedded database engine for .NET applications that need persistent, queryable storage without standing up a database server.

Full documentation | hattricklabs.com


Installation

dotnet add package HatTrick.MemDb

The package is HatTrick.MemDb; the namespace is HatTrick.Data:

using HatTrick.Data;

Quick Start

using System;
using HatTrick.Data;

public class Person
{
    public long Id { get; set; }
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
    public DateTime BirthDate { get; set; }
}

class Program
{
    static void Main()
    {
        // Configure — once at startup, before any Open calls.
        MemDb.ConfigureFor<Person>("people", @"C:\data\people")
             .Register();

        // Open — dispose flushes pending writes and releases file handles.
        using (var db = MemDb.Open<Person>("people"))
        {
            var person = new Person
            {
                FirstName = "Eric",
                LastName = "Cartman",
                BirthDate = new DateTime(2014, 5, 13)
            };

            // Insert — id auto-assigned and captured via callback.
            db.Insert(person, id => person.Id = id);

            // Update — by id.
            db.Update(p => p.MiddleName = "Theodore", person.Id);

            // Find — returns a deep clone, never a cache reference.
            var found = db.Find(person.Id);
            Console.WriteLine($"{found.FirstName} {found.MiddleName} {found.LastName}");
        }
    }
}
Eric Theodore Cartman

Why MemDb

  • In-memory with file-backed persistence — reads from RAM; writes appended to disk on a configurable flush interval and on dispose.
  • Native C# queries — filtering, sorting, aggregation, and query-scoped writes via a fluent query builder. No SQL.
  • In-process thread safety — all operations within a process are safe without additional locking.
  • Record-level encryption (AES-256), online snapshots, and archive/restore to any historical timestamp.

See the full documentation for configuration, queries, indexes, encryption, snapshots, and tuning.


License

Apache-2.0 — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.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
6.2.2 114 6/24/2026
6.2.1 103 6/20/2026

Fix: AccessMode.AppendOnly datasets can now call Snapshot() (previously threw InvalidOperationException).