-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from ignatandrei/Dapper.AOT
Dapper.aot
- Loading branch information
Showing
33 changed files
with
711 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
<h1>RSCG nr 174 : Dapper.AOT</h1> | ||
|
||
<h2>Info</h2> | ||
Nuget : <a href="https://www.nuget.org/packages/Dapper.AOT/" target="_blank">https://www.nuget.org/packages/Dapper.AOT/</a> | ||
|
||
<p>You can find more details at : <a href="https://aot.dapperlib.dev/" target="_blank"> https://aot.dapperlib.dev/</a></p> | ||
|
||
<p>Author :Marc Gravell</p> | ||
|
||
<p>Source : <a href="https://github.com/DapperLib/DapperAOT" target="_blank">https://github.com/DapperLib/DapperAOT</a> </p> | ||
|
||
<h2>About</h2> | ||
|
||
Generating AOT code for Dapper -hydrating classes from SQL queries. | ||
|
||
<h2> | ||
How to use | ||
</h2> | ||
<h3> | ||
Add reference to the <a href="https://www.nuget.org/packages/Dapper.AOT/" target="_blank">Dapper.AOT</a> in the csproj | ||
</h3> | ||
<img src="images/Dapper.AOT/DapperDemo.csproj.png" width="580" height="580" /> | ||
|
||
<h3>This was for me the <b>starting</b> code</h3> | ||
|
||
<br /> | ||
I have <b>coded</b> the file DapperDemo.csproj | ||
<br /> | ||
<img src="images/Dapper.AOT/csFiles/DapperDemo.csproj.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file Program.cs | ||
<br /> | ||
<img src="images/Dapper.AOT/csFiles/Program.cs.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file Product.cs | ||
<br /> | ||
<img src="images/Dapper.AOT/csFiles/Product.cs.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file globals.cs | ||
<br /> | ||
<img src="images/Dapper.AOT/csFiles/globals.cs.png" width="580" height="580" /> | ||
<hr /> | ||
<h3>And here are the <i>generated</i> files</h3> | ||
|
||
<br /> | ||
The file <i>generated</i> is DapperDemo.generated.cs | ||
<br /> | ||
<img src="images/Dapper.AOT/generated/DapperDemo.generated.cs.png" width="580" height="580" /> | ||
|
||
<p> | ||
You can download the code and this page as pdf from | ||
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/Dapper.AOT'> | ||
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Dapper.AOT | ||
</a> | ||
</p> | ||
|
||
|
||
<p> | ||
You can see the whole list at | ||
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'> | ||
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG | ||
</a> | ||
</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"generator":{ | ||
"name":"Dapper.AOT", | ||
"nuget":[ | ||
"https://www.nuget.org/packages/Dapper.AOT/" | ||
], | ||
"link":"https://aot.dapperlib.dev/", | ||
"author":"Marc Gravell", | ||
"source":"https://github.com/DapperLib/DapperAOT" | ||
}, | ||
"data":{ | ||
"goodFor":["Generating AOT code for Dapper -hydrating classes from SQL queries."], | ||
"csprojDemo":"DapperDemo.csproj", | ||
"csFiles":["DapperDemo.csproj","Program.cs","Product.cs","globals.cs"], | ||
"excludeDirectoryGenerated":[""], | ||
"includeAdditionalFiles":[""] | ||
}, | ||
"links":{ | ||
"blog":"", | ||
"video":"" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Build time (AOT) tools for Dapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Let's face it: ADO.NET is a complicated API, and writing "good" ADO.NET code by hand is time consuming and error-prone. But a lot of times you also don't want | ||
the ceremony of an ORM like EF or LLBLGenPro - you just want to execute SQL! | ||
|
||
For years now, Dapper helped by providing a great low-friction way of talking to arbitrary ADO.NET databases, handling command preparation, invocation, and result parsing. | ||
|
||
Dapper.AOT radically changes how Dapper works, generating the necessary code *during build*, and offers a range of usage guidance to improve how you use Dapper. | ||
|
||
[Getting Started](https://aot.dapperlib.dev/gettingstarted) | [Documentation](https://aot.dapperlib.dev/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
{ | ||
"$schema": "https://aka.ms/codetour-schema", | ||
"title": "Dapper.AOT", | ||
"steps": | ||
[ | ||
{ | ||
"file": "DapperDemo/DapperDemo.csproj", | ||
"description": "First, we add Nuget [Dapper.AOT](https://www.nuget.org/packages/Dapper.AOT/) in csproj ", | ||
"pattern": "Dapper.AOT" | ||
} | ||
|
||
,{ | ||
"file": "DapperDemo/globals.cs", | ||
"description": "File globals.cs ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "DapperDemo/Product.cs", | ||
"description": "File Product.cs ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "DapperDemo/Program.cs", | ||
"description": "File Program.cs \r\n>> dotnet run --project DapperDemo/DapperDemo.csproj ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "DapperDemo/DapperDemo.csproj", | ||
"description": "File DapperDemo.csproj ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
|
||
,{ | ||
"file": "DapperDemo/obj/GX/Dapper.AOT.Analyzers/Dapper.CodeAnalysis.DapperInterceptorGenerator/DapperDemo.generated.cs", | ||
"description": "Generated File 1 from 1 : DapperDemo.generated.cs ", | ||
"line": 1 | ||
} | ||
|
||
], | ||
|
||
"ref": "main" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.13.35507.96 d17.13 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperDemo", "DapperDemo\DapperDemo.csproj", "{EED776BC-EFA0-4BA7-9899-900AAF235ACE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EED776BC-EFA0-4BA7-9899-900AAF235ACE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EED776BC-EFA0-4BA7-9899-900AAF235ACE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EED776BC-EFA0-4BA7-9899-900AAF235ACE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EED776BC-EFA0-4BA7-9899-900AAF235ACE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {9978A3F0-9345-49D4-AFB7-6C62B6C8E06E} | ||
EndGlobalSection | ||
EndGlobal |
22 changes: 22 additions & 0 deletions
22
v2/rscg_examples/Dapper.AOT/src/DapperDemo/DapperDemo.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Dapper" Version="2.1.35" /> | ||
<PackageReference Include="Dapper.AOT" Version="1.0.31" /> | ||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Dapper.AOT</InterceptorsPreviewNamespaces> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> | ||
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
| ||
namespace DapperDemo; | ||
internal partial class Product | ||
{ | ||
public int ID { get; set; } | ||
public string Name { get; set; } = ""; | ||
public string ProductId { get; set; } = ""; | ||
public static Product GetProduct(SqlConnection connection, int productId) => connection.QueryFirst<Product>( | ||
"select ID, Name, ProductId from Production.Product where ProductId=@productId", new { productId }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
Console.WriteLine("Hello, World!"); | ||
var p= Product.GetProduct(new SqlConnection("Server=localhost;Database=AdventureWorks2019;Trusted_Connection=True;"), 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global using Dapper; | ||
global using Microsoft.Data.SqlClient; | ||
global using DapperDemo; | ||
|
||
|
||
[module: DapperAot] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"scriptName": "Dapper.AOT", | ||
"steps": | ||
[ | ||
{"typeStep":"exec","arg":"clipchamp.exe launch"}, | ||
{"typeStep":"text","arg": "Welcome to Roslyn Examples"}, | ||
{"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"}, | ||
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"}, | ||
{"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "}, | ||
|
||
{"typeStep":"text","arg": "Today I will present Dapper.AOT . Generating AOT code for Dapper -hydrating classes from SQL queries. ."}, | ||
{"typeStep":"browser","arg":"https://www.nuget.org/packages/Dapper.AOT/"}, | ||
{"typeStep":"text","arg": "The whole example is here"}, | ||
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Dapper.AOT"}, | ||
{"typeStep":"text","arg": "You can download the code from here"}, | ||
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Dapper.AOT#download-example-net--c-"}, | ||
{"typeStep":"text","arg":"Here is the code downloaded "}, | ||
{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Dapper.AOT\\src\\DapperDemo.sln"}, | ||
{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "}, | ||
{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Dapper.AOT\\src"}, | ||
|
||
{"typeStep":"text","arg": "To use it ,you will put the Nuget Dapper.AOT into the csproj "}, | ||
|
||
{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Dapper.AOT\\src\\DapperDemo\\DapperDemo.csproj"}, | ||
|
||
{"typeStep":"text","arg": "And now I will show you an example of using Dapper.AOT"}, | ||
|
||
{"typeStep":"hide","arg": "now execute the tour in VSCode"}, | ||
{"typeStep":"tour", "arg": "src/.tours/"}, | ||
{"typeStep":"text","arg":" And I will execute the project"}, | ||
{"typeStep":"showproj", "arg":"DapperDemo.csproj"}, | ||
{"typeStep":"text","arg":" This concludes the project"}, | ||
{"typeStep":"waitseconds","arg":"30"}, | ||
{"typeStep":"text","arg": "Remember, you can download the code from here"}, | ||
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Dapper.AOT#download-example-net--c-", | ||
SpeakTest=" "}, | ||
{"typeStep":"waitseconds","arg":"30"}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<h1>Database</h1> | ||
|
||
Number RSCG: 3 | ||
Number RSCG: 4 | ||
|
||
1 [Breezy](/docs/Breezy) | ||
|
||
2 [Gedaq](/docs/Gedaq) | ||
2 [Dapper.AOT](/docs/Dapper.AOT) | ||
|
||
3 [TableStorage](/docs/TableStorage) | ||
3 [Gedaq](/docs/Gedaq) | ||
|
||
4 [TableStorage](/docs/TableStorage) | ||
|
Oops, something went wrong.