From ec4c2f53b9888f7cae567ca35d47ab5b60979e6e Mon Sep 17 00:00:00 2001 From: Michael Ameyaw Date: Tue, 16 Feb 2021 06:14:42 +0000 Subject: [PATCH 1/2] Update README.md --- README.md | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index cac58e2..8e3c296 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ The fastest way to get up and running is to call one of SqlSharpener's included <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="SqlSharpener" #> <# - // Specify paths to your *.sql files. Remember to include your tables as well! We need them to get the data types. + ````c# + // Specify paths to your *.sql files. Remember to include your tables as well! We need them to get the data types. var sqlPaths = new List(); sqlPaths.Add(Host.ResolvePath(@"..\SimpleExample.Database\dbo\Tables")); sqlPaths.Add(Host.ResolvePath(@"..\SimpleExample.Database\dbo\Stored Procedures")); @@ -52,31 +53,33 @@ The fastest way to get up and running is to call one of SqlSharpener's included t.Session = session; t.Initialize(); this.Write(t.TransformText()); +```` #> The generated .cs file will contain a class with functions for all your stored procedures, DTO objects for procedures that return records, and an interface you can used if you use dependency-injection. Whenever your database project changes, simply right-click on the .tt file and click "Run Custom Tool" to regenerate the code. # Usage - -Once the code is generated, your business layer can call it like any other function. Here is one example: - - public TaskGetDto Get(int id) - { - return storedProcedures.TaskGet(id); - } - +````c# + // Once the code is generated, your business layer can call it like any other function. Here is one example: + + public TaskGetDto Get(int id) + { + return storedProcedures.TaskGet(id); + } +```` # Dependency Injection If you use a dependency-injection framework such as Ninject, you can use the interface generated. For example: - public class DataModule : NinjectModule - { - public override void Load() - { - Bind().To(); - } - } - +````c# + public class DataModule : NinjectModule + { + public override void Load() + { + Bind().To(); + } + } +```` # Documentation Check out the [wiki](https://github.com/aeslinger0/sqlsharpener/wiki) for more info. From c628fc9d4e5a6203d46729203f809d61b29d36f6 Mon Sep 17 00:00:00 2001 From: Michael Ameyaw Date: Tue, 16 Feb 2021 06:16:36 +0000 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e3c296..cafff67 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ See the [Quick Start Guide](https://github.com/aeslinger0/sqlsharpener/wiki/Quic The fastest way to get up and running is to call one of SqlSharpener's included pre-compiled templates from your template. Add a new T4 template (\*.tt) file to your data project and set its content as follows: *(Ensure you have the correct version number in the dll path)* +````c# + <#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="$(SolutionDir)\packages\SqlSharpener.1.0.2\tools\SqlSharpener.dll" #> <#@ output extension=".cs" #> @@ -36,7 +38,6 @@ The fastest way to get up and running is to call one of SqlSharpener's included <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="SqlSharpener" #> <# - ````c# // Specify paths to your *.sql files. Remember to include your tables as well! We need them to get the data types. var sqlPaths = new List(); sqlPaths.Add(Host.ResolvePath(@"..\SimpleExample.Database\dbo\Tables")); @@ -53,8 +54,8 @@ The fastest way to get up and running is to call one of SqlSharpener's included t.Session = session; t.Initialize(); this.Write(t.TransformText()); -```` #> +```` The generated .cs file will contain a class with functions for all your stored procedures, DTO objects for procedures that return records, and an interface you can used if you use dependency-injection. Whenever your database project changes, simply right-click on the .tt file and click "Run Custom Tool" to regenerate the code.