From d3731c36bccffbd695c9db68b3d6b222f617139f Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:21:12 -0500 Subject: [PATCH 1/6] chore: Delete files --- samples/LoaderSample/LoaderSample.csproj | 23 ----------------------- samples/LoaderSample/Program.cs | 9 --------- samples/LoaderSample/sample.sql | 7 ------- samples/LoaderSample/sql/sample.sql | 4 ---- samples/ParserSample/ParserSample.csproj | 11 ----------- samples/ParserSample/Program.cs | 16 ---------------- 6 files changed, 70 deletions(-) delete mode 100644 samples/LoaderSample/LoaderSample.csproj delete mode 100644 samples/LoaderSample/Program.cs delete mode 100644 samples/LoaderSample/sample.sql delete mode 100644 samples/LoaderSample/sql/sample.sql delete mode 100644 samples/ParserSample/ParserSample.csproj delete mode 100644 samples/ParserSample/Program.cs diff --git a/samples/LoaderSample/LoaderSample.csproj b/samples/LoaderSample/LoaderSample.csproj deleted file mode 100644 index e0f9224..0000000 --- a/samples/LoaderSample/LoaderSample.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - - - - - - - - - Always - - - - - - Always - - - - diff --git a/samples/LoaderSample/Program.cs b/samples/LoaderSample/Program.cs deleted file mode 100644 index e5fbd7b..0000000 --- a/samples/LoaderSample/Program.cs +++ /dev/null @@ -1,9 +0,0 @@ -using YeSql.Net; - -var loader = new YeSqlLoader(); -var sqlStatements = loader.LoadFromFiles("./sample.sql"); -loader.LoadFromDirectories("./sql"); - -Console.Write(sqlStatements["GetUsers"]); -Console.Write(sqlStatements["GetRoles"]); -Console.Write(sqlStatements["GetProducts"]); \ No newline at end of file diff --git a/samples/LoaderSample/sample.sql b/samples/LoaderSample/sample.sql deleted file mode 100644 index 8c6a54e..0000000 --- a/samples/LoaderSample/sample.sql +++ /dev/null @@ -1,7 +0,0 @@ --- name: GetUsers --- Gets user records. -SELECT* FROM [user]; - --- name: GetRoles --- Gets role records. -SELECT* FROM [role]; diff --git a/samples/LoaderSample/sql/sample.sql b/samples/LoaderSample/sql/sample.sql deleted file mode 100644 index b814be7..0000000 --- a/samples/LoaderSample/sql/sample.sql +++ /dev/null @@ -1,4 +0,0 @@ --- name: GetProducts --- Gets a list of products. -SELECT* FROM product; --- End. \ No newline at end of file diff --git a/samples/ParserSample/ParserSample.csproj b/samples/ParserSample/ParserSample.csproj deleted file mode 100644 index c2dfa90..0000000 --- a/samples/ParserSample/ParserSample.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - - - - - - - diff --git a/samples/ParserSample/Program.cs b/samples/ParserSample/Program.cs deleted file mode 100644 index 23c1dd8..0000000 --- a/samples/ParserSample/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using YeSql.Net; - -var source = -""" - -- name: GetUsers - -- Gets user records. - SELECT* FROM user; - - -- name: GetRoles - -- Gets role records. - SELECT* FROM role; -"""; - -var sqlStatements = new YeSqlParser().ParseAndThrow(source); -Console.Write(sqlStatements["GetUsers"]); -Console.Write(sqlStatements["GetRoles"]); \ No newline at end of file From b6f1d7fff96c8e750b37ebdac8e28fd879ed0247 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:22:14 -0500 Subject: [PATCH 2/6] chore: Add nuget packages --- Directory.Packages.props | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index 18aa170..e2a9b1c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,7 +3,12 @@ true + + + + + From e361b6ed1da291d113f3c1697fea0e19465013c9 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:22:51 -0500 Subject: [PATCH 3/6] chore: Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index d40aa06..20de136 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -22,4 +22,6 @@ jobs: with: dotnet-version: ${{ matrix.dotnet-version }} - name: Test - run: dotnet test ./tests/YeSql.Net.Tests.csproj \ No newline at end of file + run: | + dotnet test ./tests/YeSql.Net.Tests.csproj + dotnet test ./samples/Example.AspNetCore.Tests/Example.AspNetCore.Tests.csproj \ No newline at end of file From 9db2a7ffe7102129113e8fe71ea202bb051a46d1 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:23:14 -0500 Subject: [PATCH 4/6] chore: Create solution file for samples --- samples/YeSql.Net.Examples.sln | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 samples/YeSql.Net.Examples.sln diff --git a/samples/YeSql.Net.Examples.sln b/samples/YeSql.Net.Examples.sln new file mode 100644 index 0000000..a5cf48c --- /dev/null +++ b/samples/YeSql.Net.Examples.sln @@ -0,0 +1,73 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YeSql.Net", "..\src\YeSql.Net.csproj", "{6BC0D80C-3A4D-4146-BC50-B7BCC25F56C2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.ConsoleApp", "Example.ConsoleApp\Example.ConsoleApp.csproj", "{A1E46E21-86C3-4EED-80EE-8ECC1D5C44F4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Parsing", "Example.Parsing\Example.Parsing.csproj", "{88E35AC6-B163-4512-BCC4-7A43F63DC4F1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Reports", "Example.Reports\Example.Reports.csproj", "{17C13E48-008D-4992-94D2-D137FAB869C8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SqlFiles", "Example.SqlFiles\Example.SqlFiles.csproj", "{CE2252EE-6758-4BA2-8969-9252D8D60BC4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.AspNetCore", "Example.AspNetCore\Example.AspNetCore.csproj", "{F1416B1C-826F-46D1-AC23-991B31C20085}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.AspNetCore.Tests", "Example.AspNetCore.Tests\Example.AspNetCore.Tests.csproj", "{9508895F-9326-424C-A9A3-F04AA05ED143}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.NetFramework", "Example.NetFramework\Example.NetFramework.csproj", "{1A171DEE-BD4A-40AC-B926-9C2C50CA82D6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{91D295C8-520D-46AF-95BC-D1E6C1E60534}" + ProjectSection(SolutionItems) = preProject + ..\Directory.Build.props = ..\Directory.Build.props + ..\Directory.Packages.props = ..\Directory.Packages.props + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6BC0D80C-3A4D-4146-BC50-B7BCC25F56C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BC0D80C-3A4D-4146-BC50-B7BCC25F56C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BC0D80C-3A4D-4146-BC50-B7BCC25F56C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BC0D80C-3A4D-4146-BC50-B7BCC25F56C2}.Release|Any CPU.Build.0 = Release|Any CPU + {A1E46E21-86C3-4EED-80EE-8ECC1D5C44F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1E46E21-86C3-4EED-80EE-8ECC1D5C44F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1E46E21-86C3-4EED-80EE-8ECC1D5C44F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1E46E21-86C3-4EED-80EE-8ECC1D5C44F4}.Release|Any CPU.Build.0 = Release|Any CPU + {88E35AC6-B163-4512-BCC4-7A43F63DC4F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88E35AC6-B163-4512-BCC4-7A43F63DC4F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88E35AC6-B163-4512-BCC4-7A43F63DC4F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88E35AC6-B163-4512-BCC4-7A43F63DC4F1}.Release|Any CPU.Build.0 = Release|Any CPU + {17C13E48-008D-4992-94D2-D137FAB869C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17C13E48-008D-4992-94D2-D137FAB869C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17C13E48-008D-4992-94D2-D137FAB869C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17C13E48-008D-4992-94D2-D137FAB869C8}.Release|Any CPU.Build.0 = Release|Any CPU + {CE2252EE-6758-4BA2-8969-9252D8D60BC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE2252EE-6758-4BA2-8969-9252D8D60BC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE2252EE-6758-4BA2-8969-9252D8D60BC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE2252EE-6758-4BA2-8969-9252D8D60BC4}.Release|Any CPU.Build.0 = Release|Any CPU + {F1416B1C-826F-46D1-AC23-991B31C20085}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1416B1C-826F-46D1-AC23-991B31C20085}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1416B1C-826F-46D1-AC23-991B31C20085}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1416B1C-826F-46D1-AC23-991B31C20085}.Release|Any CPU.Build.0 = Release|Any CPU + {9508895F-9326-424C-A9A3-F04AA05ED143}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9508895F-9326-424C-A9A3-F04AA05ED143}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9508895F-9326-424C-A9A3-F04AA05ED143}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9508895F-9326-424C-A9A3-F04AA05ED143}.Release|Any CPU.Build.0 = Release|Any CPU + {1A171DEE-BD4A-40AC-B926-9C2C50CA82D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A171DEE-BD4A-40AC-B926-9C2C50CA82D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A171DEE-BD4A-40AC-B926-9C2C50CA82D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A171DEE-BD4A-40AC-B926-9C2C50CA82D6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E9693C2C-C952-43B4-A692-F054737767CB} + EndGlobalSection +EndGlobal From 01ce13103d1f38acf03a641f03f3fb0fba5938b8 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:24:49 -0500 Subject: [PATCH 5/6] docs: Add samples on how to use YeSql library --- .../Example.AspNetCore.Tests.csproj | 26 +++++++ .../Example.AspNetCore.Tests/GlobalUsings.cs | 4 ++ samples/Example.AspNetCore.Tests/SqlTests.cs | 31 ++++++++ .../Example.AspNetCore.csproj | 20 ++++++ samples/Example.AspNetCore/Program.cs | 32 +++++++++ .../Properties/launchSettings.json | 41 +++++++++++ samples/Example.AspNetCore/SqlController.cs | 40 +++++++++++ samples/Example.AspNetCore/sample.sql | 7 ++ samples/Example.AspNetCore/sql/sample.sql | 4 ++ .../Example.ConsoleApp.csproj | 17 +++++ samples/Example.ConsoleApp/Program.cs | 10 +++ samples/Example.ConsoleApp/sample.sql | 7 ++ samples/Example.ConsoleApp/sql/sample.sql | 4 ++ samples/Example.NetFramework/App.config | 6 ++ .../Example.NetFramework.csproj | 70 +++++++++++++++++++ samples/Example.NetFramework/Program.cs | 21 ++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++ samples/Example.NetFramework/sample.sql | 7 ++ samples/Example.NetFramework/sql/sample.sql | 4 ++ .../Example.Parsing/Example.Parsing.csproj | 11 +++ samples/Example.Parsing/Program.cs | 16 +++++ .../Example.Reports/Customers/customer.sql | 2 + .../Example.Reports/Example.Reports.csproj | 12 ++++ samples/Example.Reports/order.sql | 2 + .../Example.SqlFiles/Example.SqlFiles.csproj | 16 +++++ .../ThirdParties/thirdParty.sql | 2 + samples/Example.SqlFiles/security.sql | 2 + 27 files changed, 450 insertions(+) create mode 100644 samples/Example.AspNetCore.Tests/Example.AspNetCore.Tests.csproj create mode 100644 samples/Example.AspNetCore.Tests/GlobalUsings.cs create mode 100644 samples/Example.AspNetCore.Tests/SqlTests.cs create mode 100644 samples/Example.AspNetCore/Example.AspNetCore.csproj create mode 100644 samples/Example.AspNetCore/Program.cs create mode 100644 samples/Example.AspNetCore/Properties/launchSettings.json create mode 100644 samples/Example.AspNetCore/SqlController.cs create mode 100644 samples/Example.AspNetCore/sample.sql create mode 100644 samples/Example.AspNetCore/sql/sample.sql create mode 100644 samples/Example.ConsoleApp/Example.ConsoleApp.csproj create mode 100644 samples/Example.ConsoleApp/Program.cs create mode 100644 samples/Example.ConsoleApp/sample.sql create mode 100644 samples/Example.ConsoleApp/sql/sample.sql create mode 100644 samples/Example.NetFramework/App.config create mode 100644 samples/Example.NetFramework/Example.NetFramework.csproj create mode 100644 samples/Example.NetFramework/Program.cs create mode 100644 samples/Example.NetFramework/Properties/AssemblyInfo.cs create mode 100644 samples/Example.NetFramework/sample.sql create mode 100644 samples/Example.NetFramework/sql/sample.sql create mode 100644 samples/Example.Parsing/Example.Parsing.csproj create mode 100644 samples/Example.Parsing/Program.cs create mode 100644 samples/Example.Reports/Customers/customer.sql create mode 100644 samples/Example.Reports/Example.Reports.csproj create mode 100644 samples/Example.Reports/order.sql create mode 100644 samples/Example.SqlFiles/Example.SqlFiles.csproj create mode 100644 samples/Example.SqlFiles/ThirdParties/thirdParty.sql create mode 100644 samples/Example.SqlFiles/security.sql diff --git a/samples/Example.AspNetCore.Tests/Example.AspNetCore.Tests.csproj b/samples/Example.AspNetCore.Tests/Example.AspNetCore.Tests.csproj new file mode 100644 index 0000000..c0e0826 --- /dev/null +++ b/samples/Example.AspNetCore.Tests/Example.AspNetCore.Tests.csproj @@ -0,0 +1,26 @@ + + + + false + true + true + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/samples/Example.AspNetCore.Tests/GlobalUsings.cs b/samples/Example.AspNetCore.Tests/GlobalUsings.cs new file mode 100644 index 0000000..db58734 --- /dev/null +++ b/samples/Example.AspNetCore.Tests/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using NUnit.Framework; +global using FluentAssertions; +global using Microsoft.AspNetCore.Mvc.Testing; +global using System.Net; \ No newline at end of file diff --git a/samples/Example.AspNetCore.Tests/SqlTests.cs b/samples/Example.AspNetCore.Tests/SqlTests.cs new file mode 100644 index 0000000..29846fe --- /dev/null +++ b/samples/Example.AspNetCore.Tests/SqlTests.cs @@ -0,0 +1,31 @@ +namespace Example.AspNetCore.Tests; + +public class SqlTests +{ + [TestCase("/api/Sql/GetUsersSql", "SELECT* FROM [user];")] + [TestCase("/api/Sql/GetRolesSql", "SELECT* FROM [role];")] + [TestCase("/api/Sql/GetProductsSql", "SELECT* FROM [product];")] + [TestCase("/api/Sql/GetCustomersSql", "SELECT* FROM [customer];")] + [TestCase("/api/Sql/GetOrdersSql", "SELECT* FROM [order];")] + [TestCase("/api/Sql/GetPermissionsSql", "SELECT* FROM [permission];")] + [TestCase("/api/Sql/GetThirdPartiesSql", "SELECT* FROM [third_party];")] + public async Task Get_WhenSqlCodeIsRetrieved_ShouldReturnsHttpStatusCodeOk( + string requestUri, + string expectedSql) + { + // Arrange + using var factory = new WebApplicationFactory(); + var client = factory.CreateClient(); + + // Act + var httpResponse = await client.GetAsync(requestUri); + var result = (await httpResponse + .Content + .ReadAsStringAsync()) + .TrimEnd(Environment.NewLine.ToCharArray()); + + // Asserts + httpResponse.StatusCode.Should().Be(HttpStatusCode.OK); + result.Should().Be(expectedSql); + } +} diff --git a/samples/Example.AspNetCore/Example.AspNetCore.csproj b/samples/Example.AspNetCore/Example.AspNetCore.csproj new file mode 100644 index 0000000..1e20695 --- /dev/null +++ b/samples/Example.AspNetCore/Example.AspNetCore.csproj @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Example.AspNetCore/Program.cs b/samples/Example.AspNetCore/Program.cs new file mode 100644 index 0000000..ae8fc3b --- /dev/null +++ b/samples/Example.AspNetCore/Program.cs @@ -0,0 +1,32 @@ +using YeSql.Net; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +var sqlStatements = new YeSqlLoader().Load(); +builder.Services.AddSingleton(sqlStatements); +builder.Services.AddControllers(); + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); + +public partial class Program { } diff --git a/samples/Example.AspNetCore/Properties/launchSettings.json b/samples/Example.AspNetCore/Properties/launchSettings.json new file mode 100644 index 0000000..b0fd78d --- /dev/null +++ b/samples/Example.AspNetCore/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8839", + "sslPort": 44331 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5194", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7068;http://localhost:5194", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/Example.AspNetCore/SqlController.cs b/samples/Example.AspNetCore/SqlController.cs new file mode 100644 index 0000000..be90040 --- /dev/null +++ b/samples/Example.AspNetCore/SqlController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Mvc; +using YeSql.Net; + +namespace Example.AspNetCore; + +[ApiController] +[Route("api/[controller]")] +public class SqlController : ControllerBase +{ + private readonly IYeSqlCollection _sqlCollection; + public SqlController(IYeSqlCollection sqlCollection) => _sqlCollection = sqlCollection; + + [HttpGet("GetUsersSql")] + public string GetUsersSql() + => _sqlCollection["GetUsers"]; + + [HttpGet("GetRolesSql")] + public string GetRolesSql() + => _sqlCollection["GetRoles"]; + + [HttpGet("GetProductsSql")] + public string GetProductsSql() + => _sqlCollection["GetProducts"]; + + [HttpGet("GetCustomersSql")] + public string GetCustomersSql() + => _sqlCollection["GetCustomers"]; + + [HttpGet("GetOrdersSql")] + public string GetOrdersSql() + => _sqlCollection["GetOrders"]; + + [HttpGet("GetPermissionsSql")] + public string GetPermissionsSql() + => _sqlCollection["GetPermissions"]; + + [HttpGet("GetThirdPartiesSql")] + public string GetThirdPartiesSql() + => _sqlCollection["GetThirdParties"]; +} diff --git a/samples/Example.AspNetCore/sample.sql b/samples/Example.AspNetCore/sample.sql new file mode 100644 index 0000000..8c6a54e --- /dev/null +++ b/samples/Example.AspNetCore/sample.sql @@ -0,0 +1,7 @@ +-- name: GetUsers +-- Gets user records. +SELECT* FROM [user]; + +-- name: GetRoles +-- Gets role records. +SELECT* FROM [role]; diff --git a/samples/Example.AspNetCore/sql/sample.sql b/samples/Example.AspNetCore/sql/sample.sql new file mode 100644 index 0000000..42926a2 --- /dev/null +++ b/samples/Example.AspNetCore/sql/sample.sql @@ -0,0 +1,4 @@ +-- name: GetProducts +-- Gets a list of products. +SELECT* FROM [product]; +-- End. \ No newline at end of file diff --git a/samples/Example.ConsoleApp/Example.ConsoleApp.csproj b/samples/Example.ConsoleApp/Example.ConsoleApp.csproj new file mode 100644 index 0000000..95911ac --- /dev/null +++ b/samples/Example.ConsoleApp/Example.ConsoleApp.csproj @@ -0,0 +1,17 @@ + + + + Exe + + + + + + + + + + + + + diff --git a/samples/Example.ConsoleApp/Program.cs b/samples/Example.ConsoleApp/Program.cs new file mode 100644 index 0000000..5f9440b --- /dev/null +++ b/samples/Example.ConsoleApp/Program.cs @@ -0,0 +1,10 @@ +using YeSql.Net; + +var sqlStatements = new YeSqlLoader().Load(); +Console.Write(sqlStatements["GetUsers"]); +Console.Write(sqlStatements["GetRoles"]); +Console.Write(sqlStatements["GetProducts"]); +Console.Write(sqlStatements["GetCustomers"]); +Console.Write(sqlStatements["GetOrders"]); +Console.Write(sqlStatements["GetPermissions"]); +Console.Write(sqlStatements["GetThirdParties"]); diff --git a/samples/Example.ConsoleApp/sample.sql b/samples/Example.ConsoleApp/sample.sql new file mode 100644 index 0000000..8c6a54e --- /dev/null +++ b/samples/Example.ConsoleApp/sample.sql @@ -0,0 +1,7 @@ +-- name: GetUsers +-- Gets user records. +SELECT* FROM [user]; + +-- name: GetRoles +-- Gets role records. +SELECT* FROM [role]; diff --git a/samples/Example.ConsoleApp/sql/sample.sql b/samples/Example.ConsoleApp/sql/sample.sql new file mode 100644 index 0000000..42926a2 --- /dev/null +++ b/samples/Example.ConsoleApp/sql/sample.sql @@ -0,0 +1,4 @@ +-- name: GetProducts +-- Gets a list of products. +SELECT* FROM [product]; +-- End. \ No newline at end of file diff --git a/samples/Example.NetFramework/App.config b/samples/Example.NetFramework/App.config new file mode 100644 index 0000000..aee9adf --- /dev/null +++ b/samples/Example.NetFramework/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/samples/Example.NetFramework/Example.NetFramework.csproj b/samples/Example.NetFramework/Example.NetFramework.csproj new file mode 100644 index 0000000..77eb86d --- /dev/null +++ b/samples/Example.NetFramework/Example.NetFramework.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {1A171DEE-BD4A-40AC-B926-9C2C50CA82D6} + Exe + Example.NetFramework + Example.NetFramework + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {6bc0d80c-3a4d-4146-bc50-b7bcc25f56c2} + YeSql.Net + + + {17c13e48-008d-4992-94d2-d137fab869c8} + Example.Reports + + + {ce2252ee-6758-4ba2-8969-9252d8d60bc4} + Example.SqlFiles + + + + + + + \ No newline at end of file diff --git a/samples/Example.NetFramework/Program.cs b/samples/Example.NetFramework/Program.cs new file mode 100644 index 0000000..1df4c4b --- /dev/null +++ b/samples/Example.NetFramework/Program.cs @@ -0,0 +1,21 @@ +using System; +using YeSql.Net; + +namespace Example.NetFramework +{ + internal class Program + { + static void Main(string[] args) + { + var sqlStatements = new YeSqlLoader().Load(); + Console.Write(sqlStatements["GetUsers"]); + Console.Write(sqlStatements["GetRoles"]); + Console.Write(sqlStatements["GetProducts"]); + Console.Write(sqlStatements["GetCustomers"]); + Console.Write(sqlStatements["GetOrders"]); + Console.Write(sqlStatements["GetPermissions"]); + Console.Write(sqlStatements["GetThirdParties"]); + Console.ReadLine(); + } + } +} diff --git a/samples/Example.NetFramework/Properties/AssemblyInfo.cs b/samples/Example.NetFramework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ddf395d --- /dev/null +++ b/samples/Example.NetFramework/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Example.NetFramework")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Example.NetFramework")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1a171dee-bd4a-40ac-b926-9c2c50ca82d6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/Example.NetFramework/sample.sql b/samples/Example.NetFramework/sample.sql new file mode 100644 index 0000000..8c6a54e --- /dev/null +++ b/samples/Example.NetFramework/sample.sql @@ -0,0 +1,7 @@ +-- name: GetUsers +-- Gets user records. +SELECT* FROM [user]; + +-- name: GetRoles +-- Gets role records. +SELECT* FROM [role]; diff --git a/samples/Example.NetFramework/sql/sample.sql b/samples/Example.NetFramework/sql/sample.sql new file mode 100644 index 0000000..42926a2 --- /dev/null +++ b/samples/Example.NetFramework/sql/sample.sql @@ -0,0 +1,4 @@ +-- name: GetProducts +-- Gets a list of products. +SELECT* FROM [product]; +-- End. \ No newline at end of file diff --git a/samples/Example.Parsing/Example.Parsing.csproj b/samples/Example.Parsing/Example.Parsing.csproj new file mode 100644 index 0000000..625e969 --- /dev/null +++ b/samples/Example.Parsing/Example.Parsing.csproj @@ -0,0 +1,11 @@ + + + + Exe + + + + + + + diff --git a/samples/Example.Parsing/Program.cs b/samples/Example.Parsing/Program.cs new file mode 100644 index 0000000..ddcfd84 --- /dev/null +++ b/samples/Example.Parsing/Program.cs @@ -0,0 +1,16 @@ +using YeSql.Net; + +var source = +""" + -- name: GetUsers + -- Gets user records. + SELECT* FROM user; + + -- name: GetRoles + -- Gets role records. + SELECT* FROM role; +"""; + +var sqlStatements = new YeSqlParser().ParseAndThrow(source); +Console.Write(sqlStatements["GetUsers"]); +Console.Write(sqlStatements["GetRoles"]); \ No newline at end of file diff --git a/samples/Example.Reports/Customers/customer.sql b/samples/Example.Reports/Customers/customer.sql new file mode 100644 index 0000000..c90f9d8 --- /dev/null +++ b/samples/Example.Reports/Customers/customer.sql @@ -0,0 +1,2 @@ +-- name: GetCustomers +SELECT* FROM [customer]; \ No newline at end of file diff --git a/samples/Example.Reports/Example.Reports.csproj b/samples/Example.Reports/Example.Reports.csproj new file mode 100644 index 0000000..f51184e --- /dev/null +++ b/samples/Example.Reports/Example.Reports.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + latest + + + + + + + diff --git a/samples/Example.Reports/order.sql b/samples/Example.Reports/order.sql new file mode 100644 index 0000000..11f4b3f --- /dev/null +++ b/samples/Example.Reports/order.sql @@ -0,0 +1,2 @@ +-- name: GetOrders +SELECT* FROM [order]; \ No newline at end of file diff --git a/samples/Example.SqlFiles/Example.SqlFiles.csproj b/samples/Example.SqlFiles/Example.SqlFiles.csproj new file mode 100644 index 0000000..773bc1e --- /dev/null +++ b/samples/Example.SqlFiles/Example.SqlFiles.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + latest + + + + + + + + + + + diff --git a/samples/Example.SqlFiles/ThirdParties/thirdParty.sql b/samples/Example.SqlFiles/ThirdParties/thirdParty.sql new file mode 100644 index 0000000..9953bde --- /dev/null +++ b/samples/Example.SqlFiles/ThirdParties/thirdParty.sql @@ -0,0 +1,2 @@ +-- name: GetThirdParties +SELECT* FROM [third_party]; \ No newline at end of file diff --git a/samples/Example.SqlFiles/security.sql b/samples/Example.SqlFiles/security.sql new file mode 100644 index 0000000..16a7a86 --- /dev/null +++ b/samples/Example.SqlFiles/security.sql @@ -0,0 +1,2 @@ +-- name: GetPermissions +SELECT* FROM [permission]; \ No newline at end of file From 2e4aabd109e6e7faf66a34ddb6a0549ab61a3a01 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 3 Jan 2024 19:33:18 -0500 Subject: [PATCH 6/6] chore: Add sample projects to the solution file Only three basic projects were added. --- YeSql.Net.sln | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/YeSql.Net.sln b/YeSql.Net.sln index c2b131f..51c4ad1 100644 --- a/YeSql.Net.sln +++ b/YeSql.Net.sln @@ -7,9 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YeSql.Net", "src\YeSql.Net. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YeSql.Net.Tests", "tests\YeSql.Net.Tests.csproj", "{A057DB65-24DF-4D36-9C35-78F96B54F95D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParserSample", "samples\ParserSample\ParserSample.csproj", "{CCC6D826-5D29-428A-AAE6-FD3E1D61BB8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.ConsoleApp", "samples\Example.ConsoleApp\Example.ConsoleApp.csproj", "{52A8D12E-EC36-441C-939D-DEE30822C09B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoaderSample", "samples\LoaderSample\LoaderSample.csproj", "{B62F5C67-64F7-4BFC-A0AE-DE04B6A64D5E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Reports", "samples\Example.Reports\Example.Reports.csproj", "{8A45DB52-0C49-4DA8-AFA4-0B1853EB4CC4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SqlFiles", "samples\Example.SqlFiles\Example.SqlFiles.csproj", "{1A5327E6-1897-4300-B08E-472C13A517B6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A2554DDC-4D44-4D81-82C3-6491F99C3159}" ProjectSection(SolutionItems) = preProject @@ -33,16 +35,23 @@ Global {A057DB65-24DF-4D36-9C35-78F96B54F95D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A057DB65-24DF-4D36-9C35-78F96B54F95D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A057DB65-24DF-4D36-9C35-78F96B54F95D}.Release|Any CPU.Build.0 = Release|Any CPU - {CCC6D826-5D29-428A-AAE6-FD3E1D61BB8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CCC6D826-5D29-428A-AAE6-FD3E1D61BB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CCC6D826-5D29-428A-AAE6-FD3E1D61BB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CCC6D826-5D29-428A-AAE6-FD3E1D61BB8D}.Release|Any CPU.Build.0 = Release|Any CPU - {B62F5C67-64F7-4BFC-A0AE-DE04B6A64D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B62F5C67-64F7-4BFC-A0AE-DE04B6A64D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B62F5C67-64F7-4BFC-A0AE-DE04B6A64D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B62F5C67-64F7-4BFC-A0AE-DE04B6A64D5E}.Release|Any CPU.Build.0 = Release|Any CPU + {52A8D12E-EC36-441C-939D-DEE30822C09B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52A8D12E-EC36-441C-939D-DEE30822C09B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52A8D12E-EC36-441C-939D-DEE30822C09B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52A8D12E-EC36-441C-939D-DEE30822C09B}.Release|Any CPU.Build.0 = Release|Any CPU + {8A45DB52-0C49-4DA8-AFA4-0B1853EB4CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A45DB52-0C49-4DA8-AFA4-0B1853EB4CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A45DB52-0C49-4DA8-AFA4-0B1853EB4CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A45DB52-0C49-4DA8-AFA4-0B1853EB4CC4}.Release|Any CPU.Build.0 = Release|Any CPU + {1A5327E6-1897-4300-B08E-472C13A517B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A5327E6-1897-4300-B08E-472C13A517B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A5327E6-1897-4300-B08E-472C13A517B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A5327E6-1897-4300-B08E-472C13A517B6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C9084BD-1A26-4A59-A1C9-D7085585B2CF} + EndGlobalSection EndGlobal