SLVZ.Db 1.15.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SLVZ.Db --version 1.15.0
                    
NuGet\Install-Package SLVZ.Db -Version 1.15.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="SLVZ.Db" Version="1.15.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SLVZ.Db" Version="1.15.0" />
                    
Directory.Packages.props
<PackageReference Include="SLVZ.Db" />
                    
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 SLVZ.Db --version 1.15.0
                    
#r "nuget: SLVZ.Db, 1.15.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 SLVZ.Db@1.15.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=SLVZ.Db&version=1.15.0
                    
Install as a Cake Addin
#tool nuget:?package=SLVZ.Db&version=1.15.0
                    
Install as a Cake Tool

πŸ“¦ SLVZ Db, Simple Local File Database for C#

A lightweight, dependency-free library for storing and retrieving data locally in a file.
This works like a very simplified ORM (similar to EF Core) but stores data in a plain text file β€” perfect for small projects, configs, or apps that don’t require a real database.


Features

  • Store and retrieve data without an external database
  • Supports primitive data types (int, string, bool, double, enum, ...)
  • Full CRUD operations (Append, Get, Update, Remove)
  • Data stored in a human-readable plain text format
  • Supports multiple models with separate database classes

How to Use

1. Create Your Data Model

enum Role
{
    Admin,
    User
}

class myModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    public Role Role { get; set; }
    public double Grade { get; set; }
    public bool IsActive { get; set; }
}


2. Create Your Database Context

class myDB : DbContext<myModel>
{
    public override void Configuration()
    {
        SetConfig($"{Environment.CurrentDirectory}/slvz.db", "ID", "AES_KEY");
        // First argument: Database file full path
        // Second argument: Property name to be used as the unique key
        // Third argument: This is optional, If you want your database be encrypted, add AES_KEY to the third argument
    }
}



3. Example Usage

var db = new myDB();

// Add 3 users
await db.Append(new myModel
{
    ID = 1,
    Name = "Ashkan",
    Grade = 19.234,
    IsActive = true,
    Role = Role.Admin
});
await db.Append(new myModel
{
    ID = 2,
    Name = "Arash",
    Grade = 21.992,
    IsActive = true,
    Role = Role.User
});
await db.Append(new myModel
{
    ID = 3,
    Name = "Baran",
    Grade = 18.224452,
    IsActive = false,
    Role = Role.User
});

// Get all models
var models = await db.Get();

// Modify one model
models.Find(x => x.ID == 3).IsActive = true;

// Update it in the database
await db.Update(models.Find(x => x.ID == 3));

// Delete a model
// await db.Remove(3);

// Get a single model by ID
var model = await db.Get(3);

Console.WriteLine("Done");



API Reference

Append(TModel model)

Adds a single model to the database file.

  • Parameters:
    model β€” An instance of your model. Must match the configured model type.

Append(List<TModel> models)

Adds multiple models to the database at once.

  • Parameters:
    models β€” A list of model instances. All must match the configured model type.

List<TModel> Get()

Retrieves all models stored in the database.

  • Returns:
    A list of all models. Returns an empty list if no data file exists.

TModel Get(T id)

Retrieves a single model by its key property.

  • Parameters:
    key β€” The value of the key property to search for.

  • Returns:
    The model matching the key, or a new default instance if not found.


Update(TModel model)

Updates an existing model in the database.

  • Parameters:
    model β€” The updated model instance. The key property must match an existing entry.

AvailablePrimaryKey(List<T> recordKeys)

Return the first available primary key from database. You can send it a list if id's and it will return you the first ID that hasn't used


Remove(T id)

Deletes a model from the database by its key.

  • Parameters:
    key β€” The key value of the model to delete.

πŸ‘¨β€πŸ’» Author: SLVZ

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.
  • net10.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
1.21.0 97 2/6/2026
1.19.0 104 12/30/2025
1.18.0 159 12/26/2025
1.17.0 167 12/26/2025
1.16.0 187 12/25/2025
1.15.0 126 12/12/2025
1.14.0 154 11/15/2025
1.13.0 235 11/14/2025