using Dapper;
using Microsoft.Data.Sqlite;
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
var connection = new SqliteConnection("DataSource=dbdb");
var brands = connection.Query<Brand>("SELECT * FROM brands");
foreach (Brand brand in brands)
{
Console.WriteLine($"{brand.Id} {brand.Title} {brand.CompanyAddress}");
}
var clothes = connection.Query<Clothes>("SELECT * FROM clothes");
foreach (Clothes cloth in clothes)
{
Console.WriteLine($"{cloth.Id}, {cloth.Title}, {cloth.price}, {cloth.BrandId}");
}
var title = Console.ReadLine();
var companyName = Console.ReadLine();
var companyAddress = Console.ReadLine();
var id = connection.QuerySingle<int>("INSERT INTO brands (title, company_name, company_address ) VALUES(@Title, @CompanyName, @CompanyAddress); SELECT last_insert_rowid();", new {Title = title, CompanyName = companyName, CompanyAddress = companyAddress});
Console.WriteLine($"Успещно создан бренд номер {id}");