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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<h1 align="center">LiteDbContext</h1>
<div align="center">
A light-weight async wrapper around LiteDB
</div>
Key Features:
- Modern C#
- Supports cancellations
Usage
- 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; }
}
- 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;
}
}
- 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 | Versions 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.
-
net8.0
- LiteDB (>= 5.0.21)
- Microsoft.Extensions.Options (>= 8.0.2)
-
net9.0
- LiteDB (>= 5.0.21)
- Microsoft.Extensions.Options (>= 9.0.2)
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 |