Quick Start Guide

Get up and running with REDB in minutes

Fastest way to start
dotnet new install redb.Templates dotnet new redb -n MyApp --db postgres dotnet run
Working project with CRUD and tree queries in 30 seconds. Supports --db mssql and --pro true.
~10 min

This guide covers the essential CRUD operations: Create, Read, Update, Delete, and Query. Follow along to build your first REDB-powered application.

1

Installation

Install REDB packages via NuGet. Choose your database provider:

bash
# For PostgreSQL
dotnet add package redb.Postgres

# For SQL Server
dotnet add package redb.MSSql

# For Pro features (advanced queries, bulk operations)
dotnet add package redb.Postgres.Pro
dotnet add package redb.MSSql.Pro
2

Configuration

Register REDB services in your Program.cs:

csharp
// Free version
services.AddRedb(options => options
    .UsePostgres("Host=localhost;Database=mydb;Username=user;Password=pass"));

// Pro version with license
services.AddRedbPro(options => options
    //.WithLicense(License)
    .Configure(c =>
    {
        c.EavSaveStrategy = EavSaveStrategy.ChangeTracking;
        //c.EnablePropsCache = false;
        //c.PropsCacheMaxSize = 10000;
        //c.PropsCacheTtl = TimeSpan.FromMinutes(60);
    })
    .UsePostgres("Host=localhost;Port=5432;Username=postgres;Password=***;Database=redb;Pooling=true;Include Error Detail=true;Options=-c jit=off")
    //.UseMsSql("Server=localhost;Database=redb;User Id=sa;Password=***;TrustServerCertificate=true;Command Timeout=600;")
    );
3

Define Your Model

Create a Props class with the [RedbScheme] attribute. This is your business entity - no database tables to create, no migrations to write:

csharp
using redb.Core.Attributes;

[RedbScheme("Product catalog")]
public class ProductProps
{
    public string Name { get; set; } = "";
    public string? Description { get; set; }
    public decimal Price { get; set; }
    public string[] Tags { get; set; } = [];
    public bool IsActive { get; set; } = true;
}
4

Create - SaveAsync

Create and save a new object. The SaveAsync method returns the generated ID:

csharp
var product = new RedbObject<ProductProps>
{
    name = "Widget Pro base name",
    Props = new ProductProps
    {
        Name = "Widget Pro",
        Description = "A professional widget",
        Price = 99.99m,
        Tags = ["electronics", "tools"],
        IsActive = true
    }
};

var id = await redb.SaveAsync(product);
// id now contains the generated object ID
5

Read - LoadAsync

Load an object by its ID. Returns the complete object with all properties:

csharp
var loaded = await redb.LoadAsync<ProductProps>(id);

// Access properties
var name = loaded.Props.Name;
var price = loaded.Props.Price;

// or
if (loaded != null) {
    var product = (ProductProps)loaded;
    var name = product.Name;
    var price = product.Price;
}
6

Query - Where

Filter data using familiar LINQ syntax. All conditions compile to native SQL:

csharp
// Simple filter
var expensive = await redb.Query<ProductProps>()
    .Where(p => p.Price > 75000m)
    .Take(100)
    .ToListAsync();

// AND condition
var filtered = await redb.Query<ProductProps>()
    .Where(p => p.Price >= 30 && p.Price < 100)
    .ToListAsync();

// OR condition
var mixed = await redb.Query<ProductProps>()
    .Where(p => p.Price < 10 || p.Price > 90000m)
    .ToListAsync();

// NOT equal
var notWidgets = await redb.Query<ProductProps>()
    .Where(p => p.Name != "Widget")
    .ToListAsync();
7

Count - CountAsync

Get the count of objects matching your criteria:

csharp
// Total count
var totalCount = await redb.Query<ProductProps>().CountAsync();

// Filtered count
var activeCount = await redb.Query<ProductProps>()
    .Where(p => p.IsActive)
    .CountAsync();
8

Delete - DeleteAsync

Remove an object by ID. The object is permanently deleted:

csharp
// Delete by ID
await redb.DeleteAsync(id);

// Verify deletion
var deleted = await redb.LoadAsync<ProductProps>(id);
// deleted will be null

Next Steps