GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - andygjp/ExpressionToSql: Convert an Expression into a query string that works with Dapper.

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
ExpressionToSql.sln
ExpressionToSql.sln
 
 
README.md
README.md
 
 
build.cmd
build.cmd
 
 
build.sh
build.sh
 
 
license.md
license.md
 
 
remove-sqllocaldb-instances.ps1
remove-sqllocaldb-instances.ps1
 
 

Repository files navigation

ExpressionToSql

Package Status
ExpressionToSql NuGet version
ExpressionToSql.Dapper NuGet version
AppVeyor

You can write a strongly typed query and have it converted to a query that Dapper understands. Like so:

var postcode = "BL";
var query = Sql.Select((Address x) => new { x.Id, x.Postcode }).Where(x => x.Id > 10 && x.Postcode != postcode).ToString();
// "SELECT a.[Id], a.[Postcode] FROM [dbo].[Address] AS a WHERE a.[Id] > 10 AND a.[Postcode] <> @postcode"

Or:

var query = Sql.Select((Address x) => 1, "TableName").Where(x => x.Id == 1001).ToString();
// "SELECT 1 FROM [dbo].TableName AS a WHERE a.[Id] = 1001

ExpressionToSql.Dapper

You can write the same strongly typed query and pass it directly to Dapper, like so:

IEnumerable<Person> person = await _conn.QueryAsync(Sql.Select((Person x) => x).Where(x => x.Id == 2));
// "SELECT a.[Id], a.[Name] FROM [dbo].[Person] AS a WHERE a.[Id] = 2"

TODO

  • Add support for joins

About

Convert an Expression into a query string that works with Dapper.

Topics

dapper

Resources

Readme
MIT license
Activity

Stars

17 stars

Watchers

3 watching

Forks

8 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.