BLite.Client
0.1.6
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package BLite.Client --version 0.1.6
NuGet\Install-Package BLite.Client -Version 0.1.6
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="BLite.Client" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BLite.Client" Version="0.1.6" />
<PackageReference Include="BLite.Client" />
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 BLite.Client --version 0.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BLite.Client, 0.1.6"
#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 BLite.Client@0.1.6
#: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=BLite.Client&version=0.1.6
#tool nuget:?package=BLite.Client&version=0.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BLite.Client
Official .NET SDK for BLite Server over gRPC.
What You Get
- Typed collections (
IDocumentCollection<TId, T>) - Dynamic BSON collections
- LINQ query push-down
- Transactions
- Key-value API
- Admin API (users and tenants)
Install
dotnet add package BLite.Client
1. Connect To BLite Server
using BLite.Client;
await using var client = new BLiteClient(new BLiteClientOptions
{
Host = "localhost",
Port = 2626,
ApiKey = "your-api-key",
UseTls = false
});
Port must point to the gRPC endpoint (2626 by default).
2. Typed Collections (Recommended)
using BLite.Bson;
[DocumentMapper("users")]
public class User
{
[BsonId]
public ObjectId Id { get; set; }
public string Name { get; set; } = string.Empty;
public int Age { get; set; }
}
Use the generated mapper (for example UserMapper) to get a typed collection:
var users = client.GetDocumentCollection<ObjectId, User>(new UserMapper());
await users.InsertAsync(new User
{
Id = ObjectId.NewObjectId(),
Name = "Alice",
Age = 30
});
var adults = await users.AsQueryable()
.Where(x => x.Age >= 18)
.OrderBy(x => x.Name)
.ToListAsync();
3. Dynamic BSON Collections
using BLite.Bson;
using BLite.Proto;
var sensors = client.GetDynamicCollection("sensors");
var doc = await sensors.NewDocumentAsync(["name", "temp"], b => b
.AddString("name", "room-1")
.AddDouble("temp", 21.5));
_ = await sensors.InsertAsync(doc);
var q = new QueryDescriptor
{
Collection = "sensors",
Where = new BinaryFilter
{
Field = "temp",
Op = FilterOp.Gt,
Value = ScalarValue.From(20)
}
};
await foreach (var item in sensors.QueryAsync(q))
{
// process item
}
4. Transactions
await using var tx = await client.BeginTransactionAsync();
await users.InsertAsync(new User
{
Id = ObjectId.NewObjectId(),
Name = "Bob",
Age = 41
}, tx);
await tx.CommitAsync();
5. Key-Value API
using System.Text;
await client.Kv.SetAsync("session:abc", Encoding.UTF8.GetBytes("payload"));
var value = await client.Kv.GetAsync("session:abc");
6. Admin API
using BLite.Core.Query;
var createdKey = await client.Admin.CreateUserAsync(
username: "reporting",
namespaceName: null,
databaseId: null,
permissions:
[
new UserPermission
{
Collection = "reports",
Ops = BLiteOperation.Query
}
]);
Notes
- BLite Server must be reachable on gRPC endpoint.
- In production prefer
UseTls = trueand secure secret handling for API keys. - Unsupported LINQ operators are applied client-side after streaming.
Links
- BLite Server: https://github.com/EntglDb/BLite.Server
- BLite engine: https://github.com/EntglDb/BLite
| Product | Versions 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
- BLite (>= 3.6.4)
- BLite.Proto (>= 0.1.6)
- Grpc.Net.Client (>= 2.76.0)
- MessagePack (>= 3.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.