Загрузка данных


using Dapper;

var connection = new SqliteConnection("DataSource=app.db");
connection.Open();
var cities = connection.Query<City, Country, City>(...
foreach (var city in cities)...

using var transaction = connection.BeginTransaction();
transaction.Execute("INSERT INTO countries(name) VALUES (@name)", new { name = "Германия" });
var country = transaction.QueryFirst<Country>("SELECT * FROM countries ORDER BY id DESC LIMIT 1");
transaction.Execute("INSERT INTO cities(name, population, country_id) VALUES (@name, @population, @countryId)", new { name = "Берлин", population = 4000000, countryId = country.Id });
transaction.Execute("INSERT INTO cities(name, population, country_id) VALUES (@name, @population, @countryId)", new { name = "Франкфурт на Майне", population = 1500000, countryId = country.Id });
transaction.Execute("INSERT INTO cities(name, population, country_id) VALUES (@name, @population, @countryId)", new { name = "Дрезден", population = 3100000, countryId = country.Id });
transaction.Commit();