DLinq 1.1.16
dotnet add package DLinq --version 1.1.16
NuGet\Install-Package DLinq -Version 1.1.16
<PackageReference Include="DLinq" Version="1.1.16" />
<PackageVersion Include="DLinq" Version="1.1.16" />
<PackageReference Include="DLinq" />
paket add DLinq --version 1.1.16
#r "nuget: DLinq, 1.1.16"
#:package DLinq@1.1.16
#addin nuget:?package=DLinq&version=1.1.16
#tool nuget:?package=DLinq&version=1.1.16
DLinq: Dapper LINQ-to-SQL for .NET
Overview
DLinq is a Dapper LINQ-to-SQL style library for .NET 8+, designed to simplify and accelerate database access in C# applications. It provides a type-safe, composable API for querying and mutating relational databases using LINQ-like expressions, with support for SQL Server and PostgreSQL. Use SqlQuery alone for SQL generation with your preferred data access technology.
This package has evolved from a true Linq-to-sql provider to a Linq-like provider in order to give an improved developer experience. One of the primary goals is to avoid Database as code. The developer defines the entity relationships as part of writing a DLinq query, a lot like in Sql.
By not predefining the entity relationships queries are not forced to fit a mold and developers can write queries that are more natural and easier to read. This also allows for more flexibility in the types of queries that can be written, as developers are not limited by the constraints of a predefined model.
In essence DLinq queries are more like Sql queries and less like EF and Linq.
If your looking for a library that feels more like Sql and less like defining DDL as code this might be the right fit for you.
Key Features
- LINQ-Style Fluent SQL Generation: Write expressive queries using LINQ style syntax and generate efficient SQL for your database.
- Mutation Operations: Easily perform insert, update, and delete operations with automatic SQL generation and parameterization.
- Advanced Predicate Support: Use complex predicates reducing boilerplate and risk of full-table changes.
- Transaction Management: Implicit transactions. When a transaction is started, all operations using that connection are automatically included in the transaction. No need to pass around transactions or keep track of them.
- Dapper Integration: Seamless integration with Dapper for fast data access and mapping.
- Attribute Based Mapping: Use attributes to configure table and column mappings, key properties, and more.
- Dialect Abstraction: Feature parity for SQL Server and PostgreSQL, with dialect-specific SQL generation and quoting.
- Unit Testing Friendly: Mockable Dapper provider and dependency injection support for easy unit testing.
Example Usage
using DLinq;
using Microsoft.Data.SqlClient;
var connection = new SqlConnection("your-connection-string");
var dlinq = new DLinqConnection(connection, new SqlServerDialect());
// Query with LINQ predicate
var adults = dlinq.Query<Person>(x => x.Age > 18).ToList();
// Query with SqlQuery
var query = dlinq.QueryBuilder<Person>().OrderBy(x => x.Age).Skip(2).Take(5);
var results = dlinq.Query<Person>(query).ToList();
// Query Person and project to Employee (only matching properties will be mapped)
var query = dlinq.From<Person>().OrderBy(x => x.Age).Skip(2).Take(5);
var results = dlinq.Query<Employee>(query).ToList();
// Query Person and project to Employee specifying projection with 'Select'
var query = dlinq.From<Person>().OrderBy(x => x.Age).Skip(2).Take(5)
.Select(p => new Employee { FullName = p.Name, Age = p.Age });
var results = dlinq.Query<Employee>(query).ToList();
// Insert
var inserted = dlinq.Insert(new Person { Name = "Alice", Age = 30 }, new Options { SelectAfterMutation = true });
// Update with predicate
var updated = dlinq.Update(new Person { Age = 21 }, p => p.Age > 18);
// Delete by entity
int affectedRows = dlinq.Delete(inserted);
// Delete by predicate
int affectedRows2 = dlinq.Delete<Person>(x => x.Age > 100);
// Transaction
using (var tx = dlinq.BeginTransaction())
{
dlinq.Insert(new Person { Name = "Bob" });
dlinq.Commit();
}
Getting Started
- See DLinqConnection.md, SqlQuery.md, and DataAnnotations.md for API documentation and advanced usage.
- Integration tests for both SQL Server and PostgreSQL are provided in the
DLinqIntegrationTestsproject. - Unit tests and contract tests are available in the
DLinqTestsproject.
License
This project is licensed under the MIT License. See the LICENSE file in the repository for 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 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 was computed. 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. |
-
net8.0
- Dapper (>= 2.1.72)
- Microsoft.Data.SqlClient (>= 7.0.0)
- Npgsql (>= 10.0.2)
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 |
|---|---|---|
| 1.1.16 | 99 | 5/1/2026 |
| 1.1.15 | 98 | 4/27/2026 |
| 1.1.14 | 102 | 4/22/2026 |
| 1.1.13 | 99 | 4/22/2026 |
| 1.1.12 | 122 | 4/4/2026 |
| 1.1.11 | 110 | 3/24/2026 |
| 1.1.10 | 101 | 3/24/2026 |
| 1.1.9 | 100 | 3/22/2026 |
| 1.1.8 | 109 | 3/15/2026 |
| 1.1.7 | 106 | 3/7/2026 |
| 1.1.6 | 116 | 2/28/2026 |
| 1.1.5 | 106 | 2/25/2026 |
| 1.1.4 | 99 | 2/25/2026 |
| 1.1.3 | 103 | 2/24/2026 |
| 1.1.1 | 103 | 2/21/2026 |
| 1.1.0 | 106 | 2/20/2026 |
| 1.0.9 | 105 | 2/12/2026 |
| 1.0.8 | 690 | 12/3/2025 |
| 1.0.7 | 368 | 11/30/2025 |
| 1.0.6 | 139 | 11/28/2025 |