GithubHelp home page GithubHelp logo

hnjm / trancesql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulhatch/trancesql

1.0 2.0 0.0 435 KB

TranceSQL is a user-friendly SQL library for .NET supporting multiple RDBMS platforms.

Home Page: https://www.trancesql.com

License: MIT License

C# 99.50% Dockerfile 0.19% Shell 0.31%

trancesql's Introduction

TranceSQL

NuGet version (TranceSql)

TranceSQL provides an easy to use, high performance data access interface for SQL databases. TranceSQL is an alternative to using an ORM which provides an API for creating and executing commands and mapping query results back to objects. You can think of it as sitting in between an ORM like Entity Framework in which queries are generated from object-based DSLs such as LINQ and lightweight clients like Dapper that map results but require the query be provided as a string.

TranceSQL provides a command API for modeling SQL queries and an extensible translation layer for converting results to usable objects. The command definition and command "rendering" are separated into two different steps, allowing for differences between different dialects of SQL to be accounted for in the resulting SQL command. For example SQL Server uses the TOP keyword to indicate the maximum number of rows to return from a SELECT, whereas other vendors use LIMIT or require specialized WHERE clauses. TranceSQL provides platform specific drivers to render compatible SQL code for several dialects:

  • Postgres
  • Microsoft SQL Server
  • Sqlite
  • MySql
  • Oracle

For more information, see documentation in the wiki

Basic Example

TranceSQL commands leverage collection initialization and implicit type conversion extensively to make code generation simple.

public string GetUsername(int id)
{
	var database = new SqlServerDatabase(connectionString);
	var command = new Command(database)
	{
		new Select
		{
			Column = { "FirstName" }
			From = "Users"
			Where = Condition.Equal("UserID", id)
		}
	};

	// This executes as "SELECT [FirstName] FROM [Users] WHERE [UserID] = @P1"
	var user = command.Fetch<User>();

	return user.FirstName;
}

Features

Automatic Query Parameterization

Values can be included in various query building methods. These values are automatically converted to parameters when the query is executed. In addition, parameter converters may be added to provide application-specific conversion of values to parameters.

To create a automatic parameter, use the Value class.

Deferred Execution

Deferred execution provides a way to execute multiple queries within a single command and maps the results back to each request. This can be useful for keeping your code simple when building components that compose. For example if you need some user specific information along with some page specific queries.

trancesql's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.