Roadmap › 1. .NET › Step 16
Dp

Dapper — The Micro-ORM from Basics to Advanced

What Dapper is and how it works inside, Query/QueryFirst/QuerySingle/Execute, parameters and SQL injection safety, stored procedures and output parameters, multi-mapping joins, QueryMultiple, transactions, bulk inserts and table-valued parameters, async and buffering, custom type handlers, DynamicParameters, repository and unit-of-work patterns, Dapper vs EF Core vs ADO.NET, performance and testing.
Quick revision for interview day. Print it or save it as a PDF.

Core calls

Query<T> · QueryFirst(OrDefault)<T> · QuerySingle(OrDefault)<T> · Execute · ExecuteScalar<T> · QueryMultiple · QueryUnbufferedAsync · all with Async versions and CommandDefinition for timeout/cancellation.

Parameters

Anonymous object new { Id = id } · DynamicParameters for types/size/direction · IN @ids with a collection · DbString { IsAnsi = true } for VARCHAR · never interpolate values.

Advanced

Multi-mapping Query<A,B,A>(sql, map, splitOn:) · stored procs commandType: CommandType.StoredProcedure · outputs p.Get<T>() · transactions pass tx · TVP AsTableValuedParameter · SqlBulkCopy for bulk · SqlMapper.TypeHandler<T>.

Architecture

Connection factory (singleton) · repositories (scoped) · open late, dispose early · unit of work for multi-step transactions · EF Core for writes + Dapper for reads is common.

Performance

Only needed columns · server paging · correct parameter types · fewer round trips · read the execution plan.