Nahmadov.DapperForge.SqlServer
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Nahmadov.DapperForge.SqlServer --version 1.0.0
NuGet\Install-Package Nahmadov.DapperForge.SqlServer -Version 1.0.0
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="Nahmadov.DapperForge.SqlServer" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nahmadov.DapperForge.SqlServer" Version="1.0.0" />
<PackageReference Include="Nahmadov.DapperForge.SqlServer" />
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 Nahmadov.DapperForge.SqlServer --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nahmadov.DapperForge.SqlServer, 1.0.0"
#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 Nahmadov.DapperForge.SqlServer@1.0.0
#: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=Nahmadov.DapperForge.SqlServer&version=1.0.0
#tool nuget:?package=Nahmadov.DapperForge.SqlServer&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DapperToolkit v1
Lightweight Dapper-based data access with an EF-style surface (DapperDbContext + DapperSet<TEntity>) and fluent model building. This doc is for maintainers and consumers of v1.
Highlights
- Immediate execution: no change tracker, no
SaveChanges. - Fluent model builder plus data annotation support.
- SQL generation with pluggable dialects (SqlServer, Oracle).
- Mapping conventions: table name from type or
[Table], key from[Key],Id, or{TypeName}Id. - Auto-generated keys by default; override with
Property(x => x.Id).AutoGenerated(false)or provide[DatabaseGenerated]. - Expression-to-SQL translator for
WhereAsync/FirstOrDefaultAsyncsupports comparisons, null checks, booleans, stringContains/StartsWith/EndsWith(with case-insensitive option), and collectionContains→IN. - Validation via
[Required]/[StringLength]on insert/update; read-only entities protected.
Quick Start
// Registration (SqlServer; Oracle also supported)
services.AddDapperDbContext<AppDapperDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
// Use inside a scoped service
var users = await _db.Users.WhereAsync(u => u.IsActive && u.Name.StartsWith("a"), ignoreCase: true);
var id = await _db.Users.InsertAndGetIdAsync(new User { Name = "Alice", IsActive = true });
await _db.Users.DeleteByIdAsync(id);
Mapping with fluent API:
modelBuilder.Entity<User>(b =>
{
b.ToTable("Users", "dbo");
b.Property(u => u.Name).HasColumnName("username").HasMaxLength(100).IsRequired();
b.Property(u => u.Id).AutoGenerated(false); // opt out of default identity
});
Sample App (samples/ConnectionSample)
- Demonstrates registration, seeding, CRUD, validation errors, read-only queries, and all predicate translations including
IN. - Configure user secrets under
FullSample:Provider:SqlServer(default) orOracleSqlServerConnectionStringorOracleConnectionString(fallbackConnectionStringfor SqlServer)
- Tables expected (schemata align with fluent/attribute mappings):
Customers:Id(identity),FullName(nvarchar(120) not null),Email(nvarchar(200)),City(nvarchar(100)),IsActive(bit),CreatedAt(datetime),LastLogin(datetime null; read-only in fluent config).SupportTickets:TicketId(identity),CustomerId(int FK),Title(nvarchar(200) not null),Description(nvarchar(500)),Status(nvarchar(50) not null),IsEscalated(bit),OpenedOn(datetime),ClosedOn(datetime null).AuditLogs:Id(identity),Entity(nvarchar(100)),Action(nvarchar(50)),Details(nvarchar(200)),CreatedAt(datetime). Run the sample:
cd samples/ConnectionSample
dotnet run
Core Concepts
DapperDbContextwraps a connection factory and dialect, exposes low-level Dapper wrappers plusSet<TEntity>().DapperSet<TEntity>providesGetAllAsync,FindAsync,WhereAsync(Expression),FirstOrDefaultAsync,InsertAsync,InsertAndGetIdAsync,UpdateAsync,DeleteAsync,DeleteByIdAsync.SqlGenerator<TEntity>builds SELECT/INSERT/UPDATE/DELETE; skips generated/read-only columns.EntityValidator<TEntity>enforces required/length rules and read-only restrictions before SQL.- Dialects (
ISqlDialect): identifier quoting, parameter formatting, boolean literals, insert-returning-key SQL.
Expression Translation (supported patterns)
- Comparisons:
==, !=, >, >=, <, <= - Null checks:
x.Prop == null,x.Prop != null - Booleans:
x.IsActive,!x.IsActive,x.IsActive == true/false - Strings:
Contains,StartsWith,EndsWith(optional case-insensitive lowering) - Collections:
list.Contains(x.Prop)→Prop IN (...)(empty list ⇒1=0) - Logical:
&&,||,!
Limitations (v1)
- No change tracker or
SaveChanges; operations execute immediately. - Keys assumed single-column.
- No paging helpers/soft-delete conventions.
- Expression translator intentionally limited to common filters.
- Oracle dialect returns
nullforInsertReturningIdunless extended. - No logging hooks beyond console SQL echo in
DapperDbContext.LogSql.
Testing
Run all tests:
dotnet test
Key coverage:
- SQL generation (identity handling, quoting)
- Predicate translation (booleans, nulls, LIKE, case-insensitive, IN)
- Context connection/transaction behavior with fakes
Versioning
This document and code reflect Version 1 of DapperToolkit.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Data.SqlClient (>= 6.0.2)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.SourceLink.GitHub (>= 8.0.0)
- Nahmadov.DapperForge.Core (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.