Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov committed Sep 11, 2024
1 parent e5ac8ab commit ca8ae03
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions examples/src/DapperExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@
using Ydb.Sdk.Ado;

// Init Users table
await using var connection = await new YdbDataSource().OpenConnectionAsync();
await connection.OpenAsync();

connection.ExecuteAsync("""
CREATE TABLE Users(
Id Int32,
Name Text,
Email Text,
PRIMARY KEY (Id)
);
""");

connection.ExecuteAsync("INSERT INTO Users(Id, Name, Email) VALUES ($Id, $Name, $Email)",
using var connection = new YdbDataSource().OpenConnection();

connection.Execute("""
CREATE TABLE Users(
Id Int32,
Name Text,
Email Text,
PRIMARY KEY (Id)
);
""");

connection.Execute("INSERT INTO Users(Id, Name, Email) VALUES ($Id, $Name, $Email)",
new User { Id = 1, Name = "Name", Email = "Email" });

Console.WriteLine(connection.QuerySingleAsync<User>("SELECT * FROM Users WHERE Id = $Id",
Console.WriteLine(connection.QuerySingle<User>("SELECT * FROM Users WHERE Id = $Id",
new { Id = 1 }));

await connection.ExecuteAsync("DROP TABLE Users");
connection.Execute("DROP TABLE Users");

internal class User
{
Expand Down

0 comments on commit ca8ae03

Please sign in to comment.