This commit is contained in:
EonaCat 2022-09-21 18:33:52 +02:00
parent 6340a48019
commit c018d1073b
3 changed files with 42 additions and 9 deletions

View File

@ -1,6 +1,8 @@

using EonaCat.Json.Linq;
using EonaCat.Sql.Extensions;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace EonaCat.Sql
@ -22,8 +24,13 @@ namespace EonaCat.Sql
var customerId = 2;
var result = SqlHelper.ExecuteQuery(
@"Server=EONACATLAPTOP\SQLEXPRESS;Database=AdventureWorks2019;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;",
$"SELECT * FROM Person.Person WHERE BusinessEntityID = @0 AND rowguid = @1"
, true, customerId, "D8763459-8AA8-47CC-AFF7-C9079AF79033");
$"SELECT * FROM Person.Person WHERE BusinessEntityID = @id AND rowguid = @guid",
new Dictionary<string, object>
{
{ "id", customerId },
{ "guid", "D8763459-8AA8-47CC-AFF7-C9079AF79033" },
}
);
if (result.HasResult && result.HasRows)
{
@ -31,8 +38,8 @@ namespace EonaCat.Sql
Console.WriteLine(string.Empty);
foreach (var record in result.DataSet)
{
Console.WriteLine(record.FirstName);
Console.WriteLine(record.MiddleName);
Console.WriteLine($"{record.FirstName} {record.MiddleName} lives in the database");
Console.WriteLine($"Say hello to '{record.FirstName} {record.MiddleName}'");
}
}
else
@ -51,7 +58,7 @@ namespace EonaCat.Sql
Console.WriteLine(result.Exception);
}
}
Console.ReadLine();
Console.Read();
}
}
}

View File

@ -5,8 +5,27 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\..\EonaCat.Sql\EonaCat.Sql\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\..\EonaCat.Sql\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\..\EonaCat.Sql\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
@ -14,6 +33,10 @@
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\EonaCat.Sql\EonaCat.Sql\EonaCat.Sql.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="EonaCat.Helpers">
<HintPath>..\..\..\EonaCat.Helpers\EonaCat.Helpers\bin\Debug\net6.0\EonaCat.Helpers.dll</HintPath>
@ -21,9 +44,6 @@
<Reference Include="EonaCat.Logger">
<HintPath>..\..\..\EonaCat.Logger\EonaCat.Logger\bin\Release\net6.0\EonaCat.Logger.dll</HintPath>
</Reference>
<Reference Include="EonaCat.Sql">
<HintPath>..\..\..\EonaCat.Sql\EonaCat.Sql\bin\Release\net6.0\EonaCat.Sql.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlTester", "SqlTester.csproj", "{D5E2E874-0FD2-4481-BE8C-517C382342AE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlTester", "SqlTester.csproj", "{D5E2E874-0FD2-4481-BE8C-517C382342AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EonaCat.Sql", "..\..\..\EonaCat.Sql\EonaCat.Sql\EonaCat.Sql.csproj", "{4C66F87A-3BAB-457B-A77E-92F180586E9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{D5E2E874-0FD2-4481-BE8C-517C382342AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5E2E874-0FD2-4481-BE8C-517C382342AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5E2E874-0FD2-4481-BE8C-517C382342AE}.Release|Any CPU.Build.0 = Release|Any CPU
{4C66F87A-3BAB-457B-A77E-92F180586E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C66F87A-3BAB-457B-A77E-92F180586E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C66F87A-3BAB-457B-A77E-92F180586E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C66F87A-3BAB-457B-A77E-92F180586E9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE