private void LoadSuppliers() { string querry = "SELECT * FROM supplier"; SQLiteConnection connection = new SQLiteConnection(connectionString); using (SQLiteCommand command = new SQLiteCommand(querry, connection)) { connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { long id = (long)reader["id"]; string s_name = (string)reader["s_name"]; int inregistration = Convert.ToInt32(reader["s_inregistration"]); string bank = (string)reader["s_bank"]; string headquaters = (string)reader["headquaters"]; string phone = (string)reader["s_phone"]; string employee = (string)reader["employee"]; Supplier supplier = new Supplier(id, s_name, inregistration, bank, headquaters, employee, phone); string goodsQuerry = $"Select * from good where supplier_id={id}"; using (SQLiteCommand goodCommand = new SQLiteCommand(goodsQuerry, connection)) { using (var goodReader = goodCommand.ExecuteReader()) { while (goodReader.Read()) { long g_id = (long)goodReader["g_id"]; string g_name = (string)goodReader["g_name"]; double price = Convert.ToDouble(goodReader["g_price"]); string description = (string)goodReader["g_description"]; bool taxable = bool.Parse(goodReader["taxable"].ToString()); GoodCategory category = (GoodCategory)Convert.ToInt32(goodReader["category"]); Good good = new Good(g_id, g_name, price, category, description, taxable); supplier.AddGood(good); } } } suppliers.Add(supplier); } } } }