RCommon.Linq2Db
2.4.1
dotnet add package RCommon.Linq2Db --version 2.4.1
NuGet\Install-Package RCommon.Linq2Db -Version 2.4.1
<PackageReference Include="RCommon.Linq2Db" Version="2.4.1" />
<PackageVersion Include="RCommon.Linq2Db" Version="2.4.1" />
<PackageReference Include="RCommon.Linq2Db" />
paket add RCommon.Linq2Db --version 2.4.1
#r "nuget: RCommon.Linq2Db, 2.4.1"
#:package RCommon.Linq2Db@2.4.1
#addin nuget:?package=RCommon.Linq2Db&version=2.4.1
#tool nuget:?package=RCommon.Linq2Db&version=2.4.1
RCommon.Linq2Db
Linq2Db implementation of the RCommon persistence abstractions. Provides a LINQ-enabled repository backed by Linq2Db's DataConnection, supporting composable queries, eager loading, pagination, and integration with the RCommon data store factory and domain event tracking.
Features
Linq2DbRepository<TEntity>implementingILinqRepository<T>,IReadOnlyRepository<T>, andIWriteOnlyRepository<T>- Full
IQueryable<T>support built on Linq2Db'sITable<T>for composable LINQ queries - Eager loading via
Include/ThenIncludemapped to Linq2Db'sLoadWith/ThenLoadAPI - Paginated query results with ordering support via
IPaginatedList<T> - Expression-based and specification-based querying with
FindQueryreturningIQueryable<T> - Bulk delete via Linq2Db's
DeleteAsyncon queryable expressions - Named data store support for multi-database scenarios through
IDataStoreFactory RCommonDataConnectionbase class implementingIDataStorefor seamless factory resolution- Fluent DI configuration using
AddLinqToDBContextunder the hood - Domain event tracking integrated into add, update, and delete operations
- Soft delete -- entities implementing
ISoftDeleteare automatically filtered on reads and logically deleted on writes - Multitenancy -- entities implementing
IMultiTenantare automatically filtered by tenant on reads and stamped withTenantIdon writes - Targets .NET 8, .NET 9, and .NET 10
Installation
dotnet add package RCommon.Linq2Db
Usage
// Configure in Program.cs or Startup
builder.Services.AddRCommon()
.WithPersistence<Linq2DbPersistenceBuilder>(linq2Db =>
{
linq2Db.AddDataConnection<ApplicationDataConnection>("ApplicationDb",
(serviceProvider, options) =>
options.UseSqlServer(builder.Configuration.GetConnectionString("ApplicationDb")));
linq2Db.SetDefaultDataStore(defaults =>
defaults.DefaultDataStoreName = "ApplicationDb");
});
Your data connection must inherit from RCommonDataConnection:
public class ApplicationDataConnection : RCommonDataConnection
{
public ApplicationDataConnection(DataOptions options)
: base(options) { }
}
Then inject and use the repository abstractions:
public class CustomerService
{
private readonly ILinqRepository<Customer> _customerRepo;
public CustomerService(ILinqRepository<Customer> customerRepo)
{
_customerRepo = customerRepo;
}
public async Task<ICollection<Customer>> GetActiveCustomersAsync()
{
return await _customerRepo.FindAsync(c => c.IsActive);
}
public async Task<IPaginatedList<Customer>> GetCustomersPagedAsync(int page, int pageSize)
{
return await _customerRepo.FindAsync(
c => c.IsActive,
c => c.LastName,
orderByAscending: true,
pageNumber: page,
pageSize: pageSize);
}
}
Soft Delete and Multitenancy
Linq2DbRepository<TEntity> automatically supports soft delete and multitenancy when your entities implement the opt-in interfaces:
using RCommon.Entities;
public class Customer : BusinessEntity<int>, ISoftDelete, IMultiTenant
{
public string Name { get; set; }
public bool IsDeleted { get; set; }
public string? TenantId { get; set; }
}
Reads automatically exclude soft-deleted records and scope to the current tenant:
// Both filters applied transparently
var customers = await _customerRepo.FindAsync(c => c.IsActive);
Writes automatically stamp the tenant and support logical deletion:
// TenantId stamped automatically from ITenantIdAccessor
await _customerRepo.AddAsync(new Customer { Name = "Acme" });
// Soft delete — sets IsDeleted = true, performs UPDATE via Linq2Db
await _customerRepo.DeleteAsync(customer, isSoftDelete: true);
Key Types
| Type | Description |
|---|---|
Linq2DbRepository<TEntity> |
Concrete repository using Linq2Db with full LINQ, eager loading, and CRUD support |
RCommonDataConnection |
Base DataConnection class implementing IDataStore for named data store resolution |
Linq2DbPersistenceBuilder |
Fluent builder for registering Linq2Db data connections and repository services in DI |
ILinq2DbPersistenceBuilder |
Builder interface exposing AddDataConnection<T>() for registering named data connections |
Documentation
For full documentation, visit rcommon.com.
Related Packages
- RCommon.Persistence - Core persistence abstractions (required dependency)
- RCommon.EFCore - Entity Framework Core implementation
- RCommon.Dapper - Dapper implementation
License
Licensed under the Apache License, Version 2.0.
| 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. 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. |
-
net10.0
- linq2db.Extensions (>= 6.1.0)
- RCommon.Core (>= 2.4.1)
- RCommon.Persistence (>= 2.4.1)
-
net8.0
- linq2db.Extensions (>= 6.1.0)
- RCommon.Core (>= 2.4.1)
- RCommon.Persistence (>= 2.4.1)
-
net9.0
- linq2db.Extensions (>= 6.1.0)
- RCommon.Core (>= 2.4.1)
- RCommon.Persistence (>= 2.4.1)
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 |
|---|---|---|
| 2.4.1 | 80 | 2/18/2026 |
| 2.3.2-alpha.0.3 | 38 | 2/18/2026 |
| 2.3.2-alpha.0.2 | 37 | 2/18/2026 |
| 2.3.2-alpha.0.1 | 48 | 2/9/2026 |
| 2.3.1 | 86 | 2/5/2026 |
| 2.3.0 | 90 | 2/3/2026 |
| 2.2.2-alpha.0.1 | 384 | 12/11/2025 |
| 2.2.1-alpha.0.2 | 130 | 10/24/2025 |
| 2.2.1-alpha.0.1 | 149 | 10/24/2025 |
| 2.1.11-alpha.0.2 | 127 | 10/24/2025 |
| 2.1.11-alpha.0.1 | 107 | 7/18/2025 |
| 2.1.10 | 203 | 7/17/2025 |
| 2.1.9-alpha.0.1 | 150 | 7/17/2025 |
| 2.1.2.4 | 228 | 5/21/2025 |
| 2.1.2.3 | 202 | 5/1/2025 |
| 2.1.2.2 | 348 | 1/23/2025 |
| 2.1.2.1 | 190 | 1/17/2025 |
| 2.1.2 | 159 | 1/17/2025 |
| 2.1.1.4 | 171 | 1/7/2025 |
| 0.0.0-alpha.0 | 158 | 7/17/2025 |