Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
44 posts found
Dapper.AOT: Dapper with Source Generators, Interceptors and Native AOT
Database PART 16

Dapper.AOT: Dapper with Source Generators, Interceptors and Native AOT

Why does vanilla Dapper blow up even under dotnet run once PublishAot is on? Generating the code at build time with Dapper.AOT 1.1.0: [module: DapperAot], InterceptorsNamespaces, the generated interceptor code, Native AOT publish and a startup time going from 49.8 ms to 4.3 ms, type handlers as attributes, the DAP analyzers and limitations such as QueryMultiple.

6 Nov 2026 10 min 14
Dapper Performance: Query Cache, GetRowParser and Bulk Alternatives with SqlBulkCopy and COPY
Database PART 15

Dapper Performance: Query Cache, GetRowParser and Bulk Alternatives with SqlBulkCopy and COPY

What Dapper's query cache holds and why it draws a saw blade, when CommandFlags.NoCache is needed, choosing a type per row with GetRowParser, and for the bulk operations Dapper lacks: a transaction on SQLite, SqlBulkCopy on SQL Server and COPY on PostgreSQL, all with real measurements, closing with BenchmarkDotNet.

6 Nov 2026 11 min 12
Dynamic SQL with Dapper: SqlBuilder, Safe Filters and Contrib, Dommel, Dapper Plus
Database PART 14

Dynamic SQL with Dapper: SqlBuilder, Safe Filters and Contrib, Dommel, Dapper Plus

Building optional filters without string concatenation: Dapper.SqlBuilder's templates and placeholders, count and page queries from one builder, safe sorting with a whitelist and the OrWhere surprise. Then a balanced look at Dapper.Contrib, Rainbow, Dommel and the commercial Dapper Plus as of November 2026.

6 Nov 2026 10 min 14
Dapper and SQL Server: TVPs, ANSI Strings, {=literal} and Parameter Sniffing
Database PART 13

Dapper and SQL Server: TVPs, ANSI Strings, {=literal} and Parameter Sniffing

Queries that return the right result but scan the whole index: the implicit conversion nvarchar parameters cause on varchar columns, Dapper's 4000-character rule, IN lists multiplying plans, table-valued parameters, filtered indexes with {=literal} and parameter sniffing, all with real logical-reads measurements.

6 Nov 2026 11 min 17
Stored Procedures with Dapper: Output, Return Value and the Auto-Detection Trap of 2.1.11
Database PART 12

Stored Procedures with Dapper: Output, Return Value and the Auto-Detection Trap of 2.1.11

SQLite has no stored procedures, so we move to SQL Server in docker: CommandType.StoredProcedure, output and return values with DynamicParameters, how SET NOCOUNT affects Execute, single-word commands mistaken for procedures since 2.1.11, and the function vs procedure difference in PostgreSQL.

6 Nov 2026 10 min 12
Type Handlers and Custom Mapping in Dapper: Guid, DateTimeOffset and CustomPropertyTypeMap
Database PART 11

Type Handlers and Custom Mapping in Dapper: Guid, DateTimeOffset and CustomPropertyTypeMap

Why does Dapper blow up when reading Guid, DateTimeOffset and TimeSpan on SQLite? We write interpreters with SqlMapper.TypeHandler<T>, see from the source why SetValue is never called, and cover the DateOnly/TimeOnly story of 2.1.86 and column mapping with CustomPropertyTypeMap.

6 Nov 2026 11 min 13
Buffered and Unbuffered Reads in Dapper: Streaming Large Result Sets
Database PART 10

Buffered and Unbuffered Reads in Dapper: Streaming Large Result Sets

We measure the difference between buffered and unbuffered reads in Dapper: an unbuffered result re-running the query on every enumeration, 191 MB versus near-zero memory on a million rows, IAsyncEnumerable streaming with QueryUnbufferedAsync, cancellation with WithCancellation and the disposed-connection trap, all with real output.

6 Nov 2026 9 min 9
QueryMultiple and GridReader in Dapper: Several Result Sets in One Round Trip
Database PART 09

QueryMultiple and GridReader in Dapper: Several Result Sets in One Round Trip

We read several result sets from one command with Dapper's QueryMultiple and GridReader: why grids are read in order and only once, loading a master-detail order in one round trip, joining two result sets in memory, the unbuffered grid trap, and when to pick it over multi-mapping, all with real output.

6 Nov 2026 10 min 9
Multi-Mapping and splitOn in Dapper: Reading Related Data in a Single Query
Database PART 08

Multi-Mapping and splitOn in Dapper: Reading Related Data in a Single Query

We see how Dapper's multi-mapping cuts rows into column slices, the default splitOn = "Id" error, custom and comma-separated splitOn, the dictionary pattern for 1-N and null behavior on a LEFT JOIN, and we measure and fix the N+1 problem with a JOIN and IN @ids.

6 Nov 2026 11 min 9
Transactions with Dapper: BeginTransaction, Commit, Rollback and TransactionScope
Database PART 07

Transactions with Dapper: BeginTransaction, Commit, Rollback and TransactionScope

Starting from a half-written order, we set up BeginTransaction, the transaction: parameter, commit and rollback-on-dispose in Dapper, and see with real output why forgetting the parameter stays silent on SQLite, how isolation levels behave, and the async and SQLite traps of TransactionScope.

6 Nov 2026 10 min 13
Async and Connection Management in Dapper: CancellationToken, Pooling and DI
Database PART 06

Async and Connection Management in Dapper: CancellationToken, Pooling and DI

We see with real output why a CancellationToken only travels through CommandDefinition in Dapper, why async on SQLite actually runs synchronously, how connection pooling helps, why sharing one connection breaks, and the connection factory pattern in ASP.NET Core.

6 Nov 2026 11 min 12
INSERT, UPDATE, DELETE with Dapper Execute: Affected Rows and the New Id
Database PART 05

INSERT, UPDATE, DELETE with Dapper Execute: Affected Rows and the New Id

We run INSERT, UPDATE and DELETE with Execute and read the affected row count, get the new id with RETURNING and last_insert_rowid(), look at SQL Server OUTPUT and PostgreSQL RETURNING, and measure why Execute with a list is not bulk.

6 Nov 2026 10 min 9
Blog Map