DataLinq 0.6.7
dotnet add package DataLinq --version 0.6.7
NuGet\Install-Package DataLinq -Version 0.6.7
<PackageReference Include="DataLinq" Version="0.6.7" />
<PackageVersion Include="DataLinq" Version="0.6.7" />
<PackageReference Include="DataLinq" />
paket add DataLinq --version 0.6.7
#r "nuget: DataLinq, 0.6.7"
#:package DataLinq@0.6.7
#addin nuget:?package=DataLinq&version=0.6.7
#tool nuget:?package=DataLinq&version=0.6.7
DataLinq
DataLinq is a lightweight, high-performance ORM that uses source generators and immutable models to prioritize data integrity, thread safety, and efficient caching. It is designed to lean heavily on the cache to trade memory usage for speed.
Goal
The aim of the library is to minimize memory allocations and maximize speed of data retrieval, with the main focus being on read-heavy applications on small to medium projects. One focus area is to solve the classical N+1 problem, making access to related entities as close as possible to reading a local variable.
Motivation
DataLinq is an exploration of combining immutability, indirect querying, and caching. It is also an exploration of using source generators to minimize the reflection overhead that usually plagues ORM libraries.
Core Philosophy
- Immutability First:
All data read from the database is represented as immutable objects, ensuring thread safety and predictable behavior. When modifications are required, DataLinq provides a mechanism to create mutable copies, update them, and synchronize the changes. - Efficient Caching:
The framework leverages both global and transaction-specific caching, dramatically reducing database hits. - LINQ Querying:
Built on LINQ, DataLinq translates supported query shapes into backend-specific commands without exposing you to the underlying complexities. - Minimize boilerplate:
Use the CLI tool to create model classes that define types and database structure, then let DataLinq generate immutable and mutable classes with the built-in source generator. - Compile time errors:
Move as many errors as possible from runtime to compile time. For example, required fields can be enforced by the compiler instead of failing only when inserting into the database. - Extensibility:
Although current support includes MySQL/MariaDB and SQLite, the modular architecture makes it possible to extend to other SQL-like data sources.
Getting Started
Installation
Install the provider package that matches your runtime database:
# MySQL and MariaDB
dotnet add package DataLinq.MySql
# SQLite
dotnet add package DataLinq.SQLite
The CLI is installed as a dotnet tool named datalinq:
dotnet tool install --global DataLinq.CLI
Current package and repo builds target .NET 8, .NET 9, and .NET 10.
Configuration
The CLI reads datalinq.json and, if present next to it, datalinq.user.json.
Minimal example:
{
"Databases": [
{
"Name": "AppDb",
"CsType": "AppDb",
"Namespace": "MyApp.Models",
"SourceDirectories": [ "Models/Source" ],
"DestinationDirectory": "Models/Generated",
"Connections": [
{
"Type": "MariaDB",
"DataSourceName": "appdb",
"ConnectionString": "Server=localhost;Database=appdb;User ID=app;Password=secret;"
}
]
}
]
}
Generate your data models directly from your database schema:
datalinq create-models -n AppDb
If your config contains more than one database, pass -n.
If the selected database contains more than one connection type, pass -t.
Code Example
var db = new MySqlDatabase<AppDb>(connectionString);
var activeUsers = db.Query().Users
.Where(x => x.IsActive)
.ToList();
var user = db.Query().Users.Single(x => x.UserId == userId);
var updatedUser = user.Mutate(x => x.DisplayName = "Updated Name").Save();
Documentation
If you want the website-first docs experience, start here:
After that, the deeper working docs are:
- Querying
- Caching and Mutation
- Supported LINQ Queries
- Transactions
- Attributes and Model Definitions
- Troubleshooting
License
DataLinq is open source and distributed under the MIT License. See the LICENSE file for more details.
| 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
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Remotion.Linq (>= 2.2.0)
- ThrowAway (>= 0.3.1)
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Remotion.Linq (>= 2.2.0)
- ThrowAway (>= 0.3.1)
-
net9.0
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Remotion.Linq (>= 2.2.0)
- ThrowAway (>= 0.3.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DataLinq:
| Package | Downloads |
|---|---|
|
DataLinq.MySql
MySQL and MariaDB support for DataLinq - a lightweight, high-performance .NET ORM using source generators for immutability and efficient caching - optimized for read-heavy applications. |
|
|
DataLinq.SQLite
SQLite support for DataLinq - a lightweight, high-performance .NET ORM using source generators for immutability and efficient caching - optimized for read-heavy applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.7 | 69 | 3/30/2026 |
| 0.6.6 | 321 | 12/18/2025 |
| 0.6.5 | 329 | 11/12/2025 |
| 0.6.4 | 298 | 8/27/2025 |
| 0.6.3 | 235 | 8/17/2025 |
| 0.6.2 | 232 | 8/17/2025 |
| 0.6.1 | 319 | 8/5/2025 |
| 0.6.0 | 191 | 7/29/2025 |
| 0.5.4 | 390 | 6/11/2025 |
| 0.5.3 | 251 | 6/4/2025 |
| 0.5.2 | 262 | 5/19/2025 |
| 0.5.1 | 260 | 4/11/2025 |
| 0.5.0 | 332 | 4/3/2025 |
| 0.4.15 | 1,625 | 5/16/2024 |
| 0.4.14 | 340 | 2/7/2024 |
| 0.4.13 | 300 | 1/30/2024 |
| 0.4.11 | 560 | 12/4/2023 |
| 0.4.10 | 260 | 11/29/2023 |
| 0.4.9 | 260 | 11/24/2023 |
| 0.4.8 | 245 | 11/23/2023 |