Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Feb 4, 2025
1 parent 9fc863f commit 1feb1c6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Gel.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gel.Examples.ExampleTODOApi
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Gel.Examples.FSharp", "examples\Gel.Examples.FSharp\Gel.Examples.FSharp.fsproj", "{F25AA805-163F-46B4-942E-B1A5EBE8383C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gel.DocGenerator", "tools\Gel.DocGenerator\Gel.DocGenerator.csproj", "{776EAE34-5A30-45B0-9277-C399CC2ABA53}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gel.DocGenerator", "tools\Gel.DocGenerator\Gel.DocGenerator.csproj", "{776EAE34-5A30-45B0-9277-C399CC2ABA53}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "examples\test\test.csproj", "{E147890F-F34E-4DF1-88A3-34FF1D3661B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -83,6 +85,10 @@ Global
{776EAE34-5A30-45B0-9277-C399CC2ABA53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{776EAE34-5A30-45B0-9277-C399CC2ABA53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{776EAE34-5A30-45B0-9277-C399CC2ABA53}.Release|Any CPU.Build.0 = Release|Any CPU
{E147890F-F34E-4DF1-88A3-34FF1D3661B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E147890F-F34E-4DF1-88A3-34FF1D3661B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E147890F-F34E-4DF1-88A3-34FF1D3661B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E147890F-F34E-4DF1-88A3-34FF1D3661B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -99,6 +105,7 @@ Global
{E38429C6-53A5-4311-8189-1F78238666DC} = {6FC214F5-C912-4D99-91B1-3E9F52A4E11B}
{F25AA805-163F-46B4-942E-B1A5EBE8383C} = {6FC214F5-C912-4D99-91B1-3E9F52A4E11B}
{776EAE34-5A30-45B0-9277-C399CC2ABA53} = {67ED9EF0-7828-44C0-8CB0-DEBD69EC94CA}
{E147890F-F34E-4DF1-88A3-34FF1D3661B2} = {6FC214F5-C912-4D99-91B1-3E9F52A4E11B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E90C94F-D693-4411-82F3-2051DE1BE052}
Expand Down
69 changes: 69 additions & 0 deletions examples/test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Gel;

// string instance = "dnwpark/test";
string instance = "_localdev";

GelConnection connection = GelConnection.Create(new(){Instance = instance});
Console.WriteLine("Connection:");
Console.WriteLine($"host={connection.Hostname}");
Console.WriteLine($"port={connection.Port}");
Console.WriteLine($"branch={connection.Branch}");
Console.WriteLine($"database={connection.Database}");
Console.WriteLine($"user={connection.Username}");
Console.WriteLine($"password={connection.Password}");
Console.WriteLine();

GelClientPool clientPool = new GelClientPool(
connection,
new GelClientPoolConfig {
SchemaNamingStrategy = INamingStrategy.SnakeCaseNamingStrategy});

Console.WriteLine("Results:");
var results = await clientPool.QueryAsync<Person>("select Person {*, [is User].status}");
for (int index = 0; index < results.Count; ++index)
{
Console.WriteLine($"[{index}] = `{results.ElementAt(index)}`");
}

var txResult = await clientPool.TransactionAsync(async tx =>
{
await tx.ExecuteAsync("insert Ghost { name := 'Casper' };");
return await tx.QueryAsync<Person>("select Person {*, [is User].status}");
});
if (txResult is not null)
{
Console.WriteLine("Tx Result:");
for (int index = 0; index < txResult.Count; ++index)
{
Console.WriteLine($"[{index}] = `{txResult.ElementAt(index)}`");
}
}

internal abstract class Person
{
public string Name { get; set; } = string.Empty;

public override string ToString()
{
return $"{GetType().Name} {{ Name = \"{Name}\" }}";
}
};

internal class User : Person
{
public string? Status { get; set; } = null;

public override string ToString()
{
string statusString = Status is not null ? '\"' + Status + '\"' : "null" ;
return $"{GetType().Name} {{ Name = \"{Name}\", Status = {statusString} }}";
}
};

internal class Admin : Person
{
};

internal class Ghost : Person
{
};
14 changes: 14 additions & 0 deletions examples/test/test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Gel.Net.Driver\Gel.Net.Driver.csproj"/>
</ItemGroup>

</Project>

0 comments on commit 1feb1c6

Please sign in to comment.