sdmap 0.17.0
dotnet add package sdmap --version 0.17.0
NuGet\Install-Package sdmap -Version 0.17.0
<PackageReference Include="sdmap" Version="0.17.0" />
paket add sdmap --version 0.17.0
#r "nuget: sdmap, 0.17.0"
// Install sdmap as a Cake Addin #addin nuget:?package=sdmap&version=0.17.0 // Install sdmap as a Cake Tool #tool nuget:?package=sdmap&version=0.17.0
sdmap
A template engine for writing dynamic sql:
sdmap has it's own benifics over other dynamic SQL package/framework (like iBatis.NET):
- Very simple Domain-Specific-Language(or DSL) to enhance the dynamic SQL expression
- Implemented by Common-Intermediate-Language(or CIL) to ensure the performance
- Visual Studio integrated, with code-highlight, code-folding and navigate-to features supported
- Support all majoy databases like MySQL, SQL Server, SQLite (whenever Dapper supports 😃)
- Even is able to extend to databases that is not relational, like Neo4j
- Fully unit test covered.
NuGet Package:
- https://www.nuget.org/packages/sdmap
- https://www.nuget.org/packages/sdmap.ext
- https://www.nuget.org/packages/sdmap.ext.Dapper
How to use? (with Dapper)
- Install package:
sdmap.ext.Dapper
You can just only install sdmap.ext.Dapper
since it will automatically install all dependencies including sdmap
and sdmap.ext
.
- Create a empty text file, and renames it into .sdmap
- Set the file "Build operation" from "None" to "Embedded Resource" in item Property Window.
- Write some SQL statements into sdmap file, a minimum sdmap file may looks as following:
sql GetUserById
{
SELECT * FROM [User] WHERE Id = @Id
}
Note: the namespace NS { ... }
is not required.
- Initialize sdmap by this code(the
Program
means the assembly where sdmap be located):
DbConnectionExtensions.SetEmbeddedSqlAssembly(typeof(Program).Assembly);
Note:
- This code MUST be running before any database operations.
- This code ONLY need to execute ONCE per process.
- There are many other ways to initialize sdmap, you SHOULD pick up one of those depending on what you need:
SetSqlDirectory
- initialize from a physical on-disk folderSetSqlDirectoryAndWatch
- initialize from a physical on-disk folder, and watch changes when edit those folder sdmap filesSetEmbeddedSqlAssembly
- initialize from a single assembly, and sdmap automatically parse all the resource file that ends with.sdmap
SetEmbeddedSqlAssemblies
- initialize from multiple assemblies, and sdmap automatically parse all the resource file that ends with.sdmap
SetSqlEmiter
- advanced, you can write your ownISdmapEmiter
.
- And you're good to go!
- If you want to emit the SQL statement manully, you may want to call:
string finalSqlToExecute = DbConnectionExtensions.EmitSql(sqlMapId, parameterObject);
Visual Studio 2022 extension:
https://marketplace.visualstudio.com/items?itemName=sdmapvstool.sdmapvstool
How to Compile
- Install .NET Core SDK(https://www.microsoft.com/net/download/core)
- Download code(
git clone https://github.com/sdcb/sdmap.git
) - JRE 1.6+ is preferred for building performance purpose but not required
- dotnet restore
- dotnet build
Release notes:
https://github.com/sdcb/sdmap/blob/master/ReleaseNotes.md
Document/Wiki
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Antlr4.Runtime (>= 4.6.6)
- System.Reflection.Emit.ILGeneration (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
-
net6.0
- Antlr4.Runtime (>= 4.6.6)
- System.Reflection.Emit.ILGeneration (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on sdmap:
Package | Downloads |
---|---|
sdmap.ext
Useful extensions for sdmap/Dapper. |
|
GenApp.Shared
Package Description |
|
ibatis2sdmap
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.17.0 | 4,636 | 12/22/2023 |
0.16.5 | 419 | 8/31/2023 |
0.16.3 | 8,669 | 8/13/2021 |
0.16.2 | 4,083 | 7/10/2019 |
0.16.1 | 18,076 | 6/6/2019 |
0.16.0 | 1,090 | 6/5/2019 |
0.15.0 | 1,090 | 12/6/2018 |
0.14.2 | 1,273 | 4/17/2018 |
0.14.1 | 1,181 | 4/8/2018 |
0.14.0.1 | 1,139 | 4/8/2018 |
0.14.0 | 1,076 | 4/3/2018 |
0.13.1.1 | 1,090 | 3/13/2018 |
0.13.1 | 991 | 3/13/2018 |
0.13.0 | 1,407 | 3/5/2018 |
0.12.0.5 | 1,439 | 2/1/2018 |
0.11.7 | 969 | 1/18/2018 |
0.11.5 | 1,881 | 8/15/2017 |
0.11.0 | 1,613 | 7/31/2017 |
0.10.8 | 1,271 | 7/20/2017 |
0.10.6 | 1,528 | 7/12/2017 |
0.10.0 | 1,722 | 3/17/2017 |
0.9.1 | 1,424 | 2/13/2017 |
0.9.0 | 1,433 | 1/11/2017 |
0.8.2 | 1,429 | 12/30/2016 |
0.8.1 | 1,446 | 12/29/2016 |
0.8.0 | 1,425 | 12/28/2016 |
0.7.1 | 1,437 | 12/20/2016 |
0.5.0 | 1,695 | 12/16/2016 |
0.4.0 | 1,433 | 11/11/2016 |