Skip to content

Dapper ​

Dapper works directly with DataVo via DataVo.Data. Because DataVoConnection implements DbConnection, Dapper's IDbConnection extension methods require no DataVo-specific adapter package.

csharp
using Dapper;
using DataVo.Data;

using var conn = new DataVoConnection("StorageMode=InMemory;DataSource=game");
conn.Open();

conn.Execute("CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(80), score INT)");
conn.Execute(
    "INSERT INTO players (id, name, score) VALUES (@Id, @Name, @Score)",
    new { Id = 1, Name = "Ada", Score = 1200 });

List<Player> top = conn
    .Query<Player>("SELECT id, name, score FROM players WHERE score >= @min", new { min = 500 })
    .ToList();

int total = conn.ExecuteScalar<int>("SELECT COUNT(*) FROM players");

Install both packages:

bash
dotnet add package DataVo.Data --prerelease
dotnet add package Dapper

Transactions & Parameterized Queries ​

Pass an IDbTransaction from conn.BeginTransaction() directly to Dapper's Execute and Query calls. Named parameters (@Id, @min) bind through DataVoCommand's prepared-statement pipeline.

csharp
using var tx = conn.BeginTransaction();

conn.Execute(
    "UPDATE players SET score = score + @bonus WHERE id = @id",
    new { bonus = 250, id = 1 },
    tx);

tx.Commit(); // or tx.Rollback()

Verified Dapper Surface ​

Tested against DataVoConnection with Dapper 2.1.35:

Dapper CallBehavior
Execute with anonymous-object parametersReturns exact rows-affected count.
Query<T> / QuerySingleOrDefault<T>Maps columns to POCO properties by name.
ExecuteScalar<T>Returns the first column of the first row.
QueryAsync<T>Completes synchronously (in-process engine).
Execute with IDbTransactionFull Commit() / Rollback() participation.

Features outside this verified set (such as multi-mapping, QueryMultiple, or list parameter expansion) pass through standard ADO.NET; validate them against your schema before relying on them.

Dapper vs. Compiled LINQ ​

AspectDapperCompiled LINQ
Query styleRaw SQL stringsCompile-time-checked C# lambdas
Row mappingReflection-based (per Dapper)Source-generated, zero reflection
Heap allocationsPer-row POCO + Dapper overhead0 B warm aggregates & buffered views
Native AOTGoverned by Dapper AOT supportFull Native AOT support
Best fitJoins, ad-hoc SQL, existing Dapper codeHot-path lookups, filtered aggregates, game loops

Both interfaces can share the same underlying database: use Dapper for flexible SQL and compiled LINQ for hot paths.

See Also ​