Skip to content

Remove Dapper dependency - replace with custom ADO.NET extensions#26

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/investigate-dapper-need
Closed

Remove Dapper dependency - replace with custom ADO.NET extensions#26
Copilot wants to merge 4 commits into
mainfrom
copilot/investigate-dapper-need

Conversation

Copilot AI commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Investigated whether Dapper adds value beyond basic ADO.NET. Conclusion: it doesn't for our use case. Replaced with lightweight extensions (~400 LOC) that provide identical API surface.

Changes

Core Implementation

  • AdoNetExtensions.cs: Drop-in replacement for Dapper methods (ExecuteAsync, QueryAsync<T>, QueryFirstOrDefaultAsync<T>, ExecuteScalarAsync<T>)
  • AmbientTransaction: AsyncLocal-based transaction detection eliminates need to thread transactions through call chains
  • DynamicParameters: Simple implementation for bulk operations

Updated Components

  • DocumentStore.cs: Changed using Dapperusing LiteDocumentStore.Data
  • MigrationRunner.cs: Wrapped Up/Down calls in ambient transaction scope
  • SchemaIntrospector.cs: Direct DataReader access for PRAGMA queries (Dapper couldn't infer dynamic column types)
  • Removed DateTimeOffsetHandler.cs (folded into SetParameterValue)

Test Adjustments

  • Replaced QueryAsync<dynamic> calls with concrete DTOs (4 test methods)
  • Added result classes for EXPLAIN QUERY PLAN and PRAGMA table_xinfo

Technical Notes

Transaction handling: SQLite doesn't expose active transactions publicly. Using AsyncLocal to track transaction scope avoids reflection and provides clean API:

await AmbientTransaction.ExecuteInScopeAsync(transaction, async () =>
{
    await migration.UpAsync(connection);  // Automatically uses transaction
});

Type mapping: Handles primitive types, DateTimeOffset (ISO 8601), JSONB blobs, and complex types via reflection. Uses EqualityComparer<T>.Default for proper null/default handling across reference and value types.

Dependencies: Dapper 2.1.66 removed. Package size reduced. One fewer supply chain dependency.

Original prompt

investigate if we actually need Dapper or if we can remove it and access the sqlite database directly. would this simplify the project and its dependencies? maybe open paths for optimizations?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 22, 2026 16:28
…ts pass

Co-authored-by: idotta <4734635+idotta@users.noreply.github.com>
Co-authored-by: idotta <4734635+idotta@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate necessity of Dapper for SQLite access Remove Dapper dependency - replace with custom ADO.NET extensions Jan 22, 2026
Copilot AI requested a review from idotta January 22, 2026 16:35
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Feb 22, 2026
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

This pull request has been automatically closed due to inactivity. Please feel free to reopen if you would like to continue working on this.

@github-actions github-actions Bot closed this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants