Table of Contents

Introduction

Dapper.SimpleSqlBuilder is a library that enhances the Dapper experience by providing a simple, efficient, and fluent way to build both static and dynamic SQL queries.

Leveraging string interpolation and fluent API, this library allows developers to construct safe and parameterized SQL queries with ease. This is achieved by leveraging FormattableString and interpolated string handlers to capture parameters and produce parameterized SQL.

Note

The library provides a feature set for building and parametrizing SQL queries, however all of Dapper's features and quirks still apply for query parameters.

Key Features

  • Provides a simple and natural way to write SQL queries using string interpolation.
  • Chainable methods and fluent APIs for building SQL queries.
  • Supports parameter reuse in queries.
  • Dependency injection support.
  • Conditional methods for building dynamic SQL queries.
  • Performant and memory efficient. Performs similarly or better when compared to Dapper's SqlBuilder.

The library provides two builders for building SQL queries:

  • Builder - for building static, dynamic and complex SQL queries.
  • Fluent Builder - for building dynamic SQL queries using fluent API.

Packages

The library provides multiple packages to suit your needs.

Dapper.SimpleSqlBuilder: A simple SQL builder for Dapper using string interpolation and fluent API for building safe static and dynamic SQL queries.

Nuget Nuget

Dapper.SimpleSqlBuilder.StrongName: A package that uses Dapper.StrongName.

Nuget Nuget

Dapper.SimpleSqlBuilder.DependencyInjection: Dependency injection extension for Dapper.SimpleSqlBuilder.

Nuget Nuget

Database Support

The library supports any database that Dapper supports. However, the library has been tested against the latest versions of MSSQL, MySQL and PostgreSQL databases.

Next Steps