Skip to content
Paul Hatcherian edited this page Nov 30, 2018 · 2 revisions

Introduction

TraceSQL is a .NET library which aims to provide low-friction access to SQL databases without the use of an ORM. The library provides an API for defining SQL commands to be set to the server and a simple, robust, and extensible mapping library to map the query results to various result types.

The Database Drivers

TranceSQL provides "drivers" for various popular databases, these wrap the appropriate ADO.NET provider and define a dialect which is used to render the actual SQL command text from the command definition specified via the API. These driver are defined their respective NuGet packages:

Database NuGet
Postgres NuGet version (TranceSql.Postgres)
SQL Server NuGet version (TranceSql.SqlServer)
Sqlite NuGet version (TranceSql.Sqlite)
MySQL NuGet version (TranceSql.MySql)
Oracle NuGet version (TranceSql.Oracle)

Once the driver is added to your project, you'll create an instance of the appropriate database using either a connection string, or (if for example you want to rotate credentials) a connection string factory and TTL.

using TranceSql.Postgres;
// ...
var db = new PostgresDatabase(connectionString);

In addition an OpenTracing ITracer instance to override the global tracer, and/or a IParameterValueExtractor may be provided to customize how value provided are transformed before being added to commands as parameters. For more information on using these arguments, see Tracing and Customization.

The Command Object

TranceSQL operations center around the Command class which holds commands and provides methods for running them. The Command class supports collection initialization, allowing for easily readable command definition.

The command constructor requires either a database instance or deferred execution context (for more information see Deferred Execution). In addition an optional operationName parameter can be specified to be used to for recording traces.

var command = new Command(db, "GetNames")
{
  new Select
  {
    Column = { "Name" },
    From = "Table"
  }
}
You can’t perform that action at this time.