LiteDbContext 1.0.0-rc.8

This is a prerelease version of LiteDbContext.
dotnet add package LiteDbContext --version 1.0.0-rc.8                
NuGet\Install-Package LiteDbContext -Version 1.0.0-rc.8                
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="LiteDbContext" Version="1.0.0-rc.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteDbContext --version 1.0.0-rc.8                
#r "nuget: LiteDbContext, 1.0.0-rc.8"                
#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.
// Install LiteDbContext as a Cake Addin
#addin nuget:?package=LiteDbContext&version=1.0.0-rc.8&prerelease

// Install LiteDbContext as a Cake Tool
#tool nuget:?package=LiteDbContext&version=1.0.0-rc.8&prerelease                

<h1 align="center">LiteDbContext</h1>

<div align="center">

A light-weight async wrapper around LiteDB

Language Dependencies Checks Coverage Version

</div>

Key Features:

  • Modern C#
  • Supports cancellations

Usage

  1. Define a LiteDbContext:
using LiteDB;

// ...

public sealed class ExampleDbContext(LiteDbOptions options) : LiteDbContext(options)
{
    // NOTE: if a `name` is not provided to `DbSet<T>(string? name)`, `[CallerMemberName]` will provide the `PropertyInfo.Name` for you, e.g. `Examples`
    public LiteDbSet<ExampleEntity> Examples => DbSet<ExampleEntity>();
}

public sealed record class ExampleEntity
{
    public required string Key { get; init; }
    public string Value { get; init; }
}
  1. Add your LiteDbContext as a service:

using LiteDB.Extensions.DependencyInjection;

// ...

IServiceCollection services;

 // ...

services.AddLiteDbContext<ExampleDbContext>(options =>
{
    options.ConnectionString = "...";

    options.Mapper.ConfigureExamples();
});

// ...

internal static class ExampleEntityConfiguration
{
    public static BsonMapper ConfigureExamples(this BsonMapper mapper)
    {
        mapper.Entity<ExampleEntity>()
            .Id(example => example.Key);

        return mapper;
    }
}
  1. Use you LiteDbContext:
public sealed class ExampleController
{
    [HttpGet]
    public async Task<ActionResult<ExampleEntity[]>> Index(
        [FromServices] ExampleDbContext context,
        [FromQuery, Required] string query)
    {
        var examples = await context.Examples.Query()
            .Where(example => example.Value.StartsWith( query ))
            .ToArrayAsync(HttpContext.RequestAborted);

        return Ok(examples);
    }
}

How'd He Do It?

Work against the database is synchronized via a queue, backed by an unbounded Channel.

See DbWorkQueue.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0-rc.8 38 2/16/2025
1.0.0-rc.7 39 2/15/2025
1.0.0-rc.6 38 2/15/2025
1.0.0-rc.5 40 2/14/2025
1.0.0-rc.4 33 2/14/2025
1.0.0-rc.3 37 2/13/2025