Skip to content

cosmez/sqlstringsgenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SqlStrings Source Generator

C# Source Generator that transforms .sql files in your project into statically-typed C# classes and fields.

Installation

dotnet add package Emm.SqlStringGenerator 

Example

create sql file

--namespace: Org.MyAppNamespace
--class: Queries
--classModifier: public

--name: CountTable
SELECT COUNT(*) FROM Table

--name: DeleteTable
DELETE FROM Table WHERE Id = @Id

include in your .csproj

<ItemGroup>
    <AdditionalFiles Include="Queries.sql" /> 
</ItemGroup>

use in your code

Console.WriteLine(Org.MyAppNamespace.Queries.CountTable);
//or 
Connection.Execute(Org.MyAppNamespace.Queries.DeleteTable, new { Id = 5 });

About

Sql Strings Source Generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages