LiteOrm.Remote 8.1.9

dotnet add package LiteOrm.Remote --version 8.1.9
                    
NuGet\Install-Package LiteOrm.Remote -Version 8.1.9
                    
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="LiteOrm.Remote" Version="8.1.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteOrm.Remote" Version="8.1.9" />
                    
Directory.Packages.props
<PackageReference Include="LiteOrm.Remote" />
                    
Project file
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 LiteOrm.Remote --version 8.1.9
                    
#r "nuget: LiteOrm.Remote, 8.1.9"
                    
#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 LiteOrm.Remote@8.1.9
                    
#: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=LiteOrm.Remote&version=8.1.9
                    
Install as a Cake Addin
#tool nuget:?package=LiteOrm.Remote&version=8.1.9
                    
Install as a Cake Tool

LiteOrm.Remote

License GitHub


📖 English Version

LiteOrm.Remote is the client-side package of LiteOrm's remote service invocation. It generates dynamic proxies for your service interfaces and forwards calls over HTTP to a LiteOrm.Remote.Server endpoint, so business code can call remote services exactly like local ones.

When to Use

  • You want to physically separate frontend apps (Web / desktop / mobile) from the database access layer.
  • Multiple clients need to share one backend service implementation.
  • You need to keep database connection strings off the client machines.

Requirements

  • .NET 8.0+ / .NET Standard 2.0 (.NET Framework 4.6.1+ compatible)
  • Dependencies: LiteOrm.Common, Castle.Core, Castle.Core.AsyncInterceptor
  • A running LiteOrm.Remote.Server endpoint to forward calls to

Installation

dotnet add package LiteOrm.Remote

Quick Start

using LiteOrm.Remote;

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddLiteOrmRemote(opts =>
{
    opts.RemoteServiceUri = new Uri("http://localhost:5000");
});
var host = builder.Build();

For authenticated connections, use StaticCredentialsResolver to obtain a ticket from the server's SignIn endpoint:

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddLiteOrmRemote(opts =>
{
    opts.RemoteServiceUri = new Uri("http://localhost:5000");

    // Register StaticCredentialsResolver via factory
    opts.CredentialsResolverFactory = sp =>
    {
        var httpClient = new HttpClient { BaseAddress = opts.RemoteServiceUri };
        return new StaticCredentialsResolver(httpClient, opts.RemoteSignInPath);
    };
});
var host = builder.Build();

// Log in once at startup (resolve the resolver from the DI container)
using (var scope = host.Services.CreateScope())
{
    var resolver = scope.ServiceProvider.GetRequiredService<ICredentialsResolver>();
    await ((StaticCredentialsResolver)resolver).LoginAsync(new RemoteCredentials
    {
        Username = "admin",
        Password = "pass",
    });
}

HttpRemoteServiceTransport calls ICredentialsResolver.GetTicketAsync on each InvokeAsync and writes the ticket to the HTTP request header.

AutoRegisterEntityServices defaults to true — the framework scans interfaces marked with [Service] and registers them as remote proxies automatically. No per-interface registration needed.

Call Remote Services Like Local Ones

using var scope = host.Services.CreateScope();
var userService = scope.ServiceProvider.GetRequiredService<IDemoUserService>();

var user = new DemoUser { UserName = "alice" };
await userService.InsertAsync(user);          // Id is written back automatically
Console.WriteLine($"Inserted user Id = {user.Id}");

Highlights

  • Transparent RPC: dynamic proxies make remote calls look like local interface calls.
  • Auto Identity Write-back: ArgumentOutAttribute carries identity values back from the server.
  • Ticket-based Authentication: ICredentialsResolver provides an identity ticket on each InvokeAsync, written to the HTTP request header (Cookie by default, or Authorization: Bearer for JWT). Built-in StaticCredentialsResolver handles login for single-user scenarios.
  • Pluggable Transport: built-in HTTP transport; swap IRemoteServiceTransport for custom transports.
  • Shared Protocol: DTOs (RemoteInvocationRequest / RemoteInvocationResponse) live in LiteOrm.Common, so client and server stay in sync.

📖 中文版本

LiteOrm.Remote 是 LiteOrm 远程服务调用的客户端包。它为服务接口生成动态代理,通过 HTTP 将调用转发到 LiteOrm.Remote.Server 端点,业务代码可以像调用本地服务一样调用远程服务。

适用场景

  • 需要将前端应用(Web / 桌面 / 移动端)与数据访问层物理隔离。
  • 多个客户端需要共享同一套后端服务实现。
  • 希望数据库连接串不暴露在客户端机器上。

环境要求

  • .NET 8.0+ / .NET Standard 2.0(兼容 .NET Framework 4.6.1+)
  • 依赖库:LiteOrm.Common、Castle.Core、Castle.Core.AsyncInterceptor
  • 需要一个运行中的 LiteOrm.Remote.Server 端点接收调用

安装

dotnet add package LiteOrm.Remote

快速入门

using LiteOrm.Remote;

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddLiteOrmRemote(opts =>
{
    opts.RemoteServiceUri = new Uri("http://localhost:5000");
});
var host = builder.Build();

已认证连接需使用 StaticCredentialsResolver,从服务端 SignIn 端点获取票据:

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddLiteOrmRemote(opts =>
{
    opts.RemoteServiceUri = new Uri("http://localhost:5000");

    // 使用工厂注册 StaticCredentialsResolver
    opts.CredentialsResolverFactory = sp =>
    {
        var httpClient = new HttpClient { BaseAddress = opts.RemoteServiceUri };
        return new StaticCredentialsResolver(httpClient, opts.RemoteSignInPath);
    };
});
var host = builder.Build();

// 启动时登录一次(从 DI 容器解析出 resolver 实例)
using (var scope = host.Services.CreateScope())
{
    var resolver = scope.ServiceProvider.GetRequiredService<ICredentialsResolver>();
    await ((StaticCredentialsResolver)resolver).LoginAsync(new RemoteCredentials
    {
        Username = "admin",
        Password = "pass",
    });
}

HttpRemoteServiceTransport 在每次 InvokeAsync 时调用 ICredentialsResolver.GetTicketAsync 获取票据并写入 HTTP 请求头。

AutoRegisterEntityServices 默认为 true,框架自动扫描带 [Service] 特性的接口并注册为远程代理,无需手动逐个注册。

像本地服务一样调用远程服务

using var scope = host.Services.CreateScope();
var userService = scope.ServiceProvider.GetRequiredService<IDemoUserService>();

var user = new DemoUser { UserName = "alice" };
await userService.InsertAsync(user);          // Id 自动回写
Console.WriteLine($"新增用户 Id = {user.Id}");

主要特性

  • 透明 RPC:动态代理让远程调用看起来与本地接口调用无异。
  • 自动 Identity 回写:通过 ArgumentOutAttribute 把服务端生成的标识值回写到客户端。
  • 票据身份认证:ICredentialsResolver 在每次 InvokeAsync 时提供身份票据并写入 HTTP 请求头(默认 Cookie,JWT 场景可改为 Authorization: Bearer)。内置 StaticCredentialsResolver 处理单用户场景的登录。
  • 可插拔传输层:内置 HTTP 传输;可实现 IRemoteServiceTransport 替换为自定义传输。
  • 共享协议:DTO(RemoteInvocationRequest / RemoteInvocationResponse)位于 LiteOrm.Common,客户端与服务端协议天然一致。

📚 相关资源 / Resources

📄 License

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
8.1.9 84 9/22/2026
8.1.6 96 9/10/2026
8.1.5 100 9/5/2026
8.0.4 123 8/6/2026
8.0.3 117 7/28/2026
8.0.2 118 7/6/2026
8.0.1 117 6/30/2026

8.1.9:
- 同步 LiteOrm.Common 8.1.9 / LiteOrm 8.1.9。