Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 2.86 KB

File metadata and controls

82 lines (57 loc) · 2.86 KB

FlexQuery.NET.Dapper

NuGet Version

SQL generation and async execution for Dapper.

When to Use This Package

Install this package when your application uses Dapper instead of Entity Framework Core. FlexQuery.NET.Dapper translates QueryOptions into parameterized, dialect-aware SQL and executes it directly via DbConnection.

Installation

dotnet add package FlexQuery.NET.Dapper

Registration

The SQL dialect is auto-detected from the DbConnection at runtime — no manual dialect configuration is required. Register your entity mapping model once at startup:

using FlexQuery.NET.Dapper.Configuration;

FlexQueryDapper.Configure(options =>
{
    options.Model.Entity<User>(entity =>
    {
        entity.ToTable("Users");
    });
    options.CommandTimeout = 60;
});

Or configure options per query:

options.CommandTimeout = 60;

Quick Start

using FlexQuery.NET.Models;

[HttpGet("users")]
public async Task<IActionResult> GetUsers([FromQuery] FlexQueryParameters parameters)
{
    await using var connection = new SqlConnection(connectionString);

    var result = await connection.FlexQueryAsync<User>(parameters, options =>
    {
        options.AllowedFields = new HashSet<string> { "Id", "Name", "Email" };
    }, cancellationToken: cancellationToken);

    return Ok(result);
}

Features

  • SQL GenerationSqlTranslator produces parameterized, injection-safe SQL
  • Dialect Support — SQL Server, PostgreSQL, MySQL, MariaDB, SQLite, and Oracle, auto-detected from the connection
  • Flat Projection — Deep select paths (e.g., Orders.Total) become LEFT JOIN with flattened aliases
  • Entity Mapping — Fluent entity-to-table mapping via ModelBuilder and IEntityTypeConfiguration<T>
  • Filtered Includes — Related collections hydrated from the include tree
  • SQL Execution Logging — Execution logs include copy-paste-ready DECLARE scripts
  • Typed DTO ResultsFlexQueryAsync<TEntity, TResponse> overloads for strongly-typed responses
  • Diagnostics — Pass a listener via the options to observe pipeline stages

Known Limitations

  • Some aggregate functions may vary by dialect

Related Packages

Documentation