surrealdb/surrealdb.net là dự án C# với 138 sao trong nhóm Backend. SurrealDB SDK for .NET
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Embedded in-memory and persistent modes (Memory, RocksDB, SurrealKV)
Dependency injection
Authentication
Live queries
Client-side transactions
How to install
dotnet add package SurrealDb.Net
Getting started
This library supports connecting to SurrealDB over the remote HTTP and WebSocket connection protocols http, https, ws, and wss.
The examples below require SurrealDB to be installed and running on port 8000.
Constructing a new SurrealDB client
You can easily create a new SurrealDB client. All you have to do is define the endpoint to the SurrealDB instance.
await using var clientHttp = new SurrealDbClient("http://127.0.0.1:8000");
await using var clientHttps = new SurrealDbClient("https://127.0.0.1:8000");
await using var clientWs = new SurrealDbClient("ws://127.0.0.1:8000/rpc");
await using var clientWss = new SurrealDbClient("wss://127.0.0.1:8000/rpc");
// Now you can call other methods including Signin & Use
Dependency injection
You can use Dependency Injection with the services.AddSurreal() function.
Default instance
var options = SurrealDbOptions
.Create()
.WithEndpoint("http://127.0.0.1:8000")
.WithNamespace("test")
.WithDatabase("test")
.WithUsername("root")
.WithPassword("root")
.Build();
services.AddSurreal(options); // Access `SurrealDbSession` scoped to the request
Then you will be able to use the ISurrealDbSession interface or SurrealDbSession class anywhere. Note that you will need to use SurrealDbSession instead of SurrealDbClient because SurrealDbClient can only be used in a Singleton context, see below.
Lifetime compatibility
Class
Singleton
Scoped
Transient
SurrealDbClient
✅
❌
❌
SurrealDbSession
❌
✅
✅
public class MyClass
{
private readonly ISurrealDbSession _db;
public MyClass(ISurrealDbSession db)
{
_db = db;
}
// ...
}
Note that the default lifetime of this service is Scoped. You can override this as follows:
It will automatically create a new SurrealDB using the Server endpoint and configure the client using the different values for namespace, database, username and password. Note that these values are optional but the endpoint is still required.
Multiple instances
Having a default instance for a project is enough most of the time, but there may be times when you'd like to target multiple SurrealDB instances, either at different addresses or at the same address but inside different NS/DBs. You can use multiple instances using Keyed service injection, as in the following example.
the default one, you can keep using ISurrealDbSession interface or SurrealDbSession class anywhere
a client for backup purpose, using the [FromKeyedServices("backup")] attribute
a client for monitoring purpose, using the [FromKeyedServices("monitoring")] attribute
Use the client
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private const string Table = "weatherForecast";
private readonly ISurrealDbSession _db;
public WeatherForecastController(ISurrealDbSession db)
{
_db = db;
}
[HttpGet]
public Task<IEnumerable<WeatherForecast>> GetAll(CancellationToken cancellationToken)
{
return _db.Select<WeatherForecast>(Table, cancellationToken);
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(string id, CancellationToken cancellationToken)
{
var weatherForecast = await _db.Select<WeatherForecast>((Table, id), cancellationToken);
if (weatherForecast is null)
return NotFound();
return Ok(weatherForecast);
}
[HttpPost]
public Task<WeatherForecast> Create(CreateWeatherForecast data, CancellationToken cancellationToken)
{
var weatherForecast = new WeatherForecast
{
Date = data.Date,
Country = data.Country,
TemperatureC = data.TemperatureC,
Summary = data.Summary
};
return _db.Create(Table, weatherForecast, cancellationToken);
}
[HttpPut]
public Task<WeatherForecast> Update(WeatherForecast data, CancellationToken cancellationToken)
{
return _db.Upsert(data, cancellationToken);
}
[HttpPatch]
public Task<IEnumerable<WeatherForecast>> PatchAll(
JsonPatchDocument<WeatherForecast> patches,
CancellationToken cancellationToken
)
{
return _db.Patch(Table, patches, cancellationToken);
}
[HttpPatch("{id}")]
public Task<WeatherForecast> Patch(
string id,
JsonPatchDocument<WeatherForecast> patches,
CancellationToken cancellationToken
)
{
return _db.Patch((Table, id), patches, cancellationToken);
}
[HttpDelete]
public Task DeleteAll(CancellationToken cancellationToken)
{
return _db.Delete(Table, cancellationToken);
}
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id, CancellationToken cancellationToken)
{
bool success = await _db.Delete((Table, id), cancellationToken);
if (!success)
return NotFound();
return Ok();
}
}
Embedded mode
SurrealDB can run embedded directly inside your .NET process — no external server needed. Three engines are available:
Package
Storage
Use case
SurrealDb.Embedded.InMemory
In-memory (volatile)
Testing, prototyping
SurrealDb.Embedded.RocksDb
RocksDB (persistent)
Local storage
SurrealDb.Embedded.SurrealKv
SurrealKV (persistent)
Local storage
Install
dotnet add package SurrealDb.Embedded.InMemory
Basic example
using SurrealDb.Embedded.InMemory;
await using var db = new SurrealDbMemoryClient();
await db.Use("test", "test");
var created = await db.Create("person", new { Name = "John", Age = 30 });
var results = await db.Select<Person>("person");
Learn more about embedding SurrealDB in the official docs.
.NET release versions
The .NET release versions must follow these rules:
Should target at least the latest LTS (Long-Term Support) version
Should target at least the latest STS (Standard-Term Support) version
SurrealDb.Net targets .NET versions following the .NET Support Policy by Microsoft. Additionally, SurrealDb.Net targets .NET Standard 2.1 explicitly to continue support of the Mono runtime (Unity, Xamarin, etc...).
Note that the support for .NET standard 2.1 will be maintained until further notice.
surrealdb/surrealdb.net thuộc nhóm Backend trên TopGit, cùng 7 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về surrealdb/surrealdb.net ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/surrealdb/surrealdb.net là nguồn chính thức.
surrealdb/surrealdb.net có phải mã nguồn mở không?
Có — surrealdb/surrealdb.net phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/surrealdb/surrealdb.net.
surrealdb/surrealdb.net là gì?
surrealdb/surrealdb.net (surrealdb/surrealdb.net) là dự án C# trên GitHub. Theo mô tả gốc: SurrealDB SDK for .NET
surrealdb/surrealdb.net so với các dự án Backend khác thế nào?
surrealdb/surrealdb.net được TopGit xếp vào nhóm Backend, với 138 sao GitHub và viết bằng C#. Xem trang chủ đề Backend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Vì sao surrealdb/surrealdb.net được xếp vào nhóm Backend?
TopGit xếp surrealdb/surrealdb.net vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "database-connector", "dotnet", "dotnet-library"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
surrealdb.net có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về surrealdb.net.