Actually, there are 2 grids, one is filled with a collection, the data in the collection is the data from the database.
Method of filling the collection
public List<Food> GetFoods() { List<Food> Foods = new List<Food>(); string query = "select * from Food"; MySqlConnection sqlcon = new MySqlConnection(ConnectionString); MySqlCommand cmd = new MySqlCommand(query, sqlcon); cmd.CommandType = System.Data.CommandType.Text; sqlcon.Open(); MySqlDataReader sqlreader = cmd.ExecuteReader(); object[] row; while (sqlreader.Read()) { row = new object[sqlreader.FieldCount]; sqlreader.GetValues(row); Foods.Add(new Food() { Name = row[0].ToString(), Belki = (decimal)row[1], Jiri = (decimal)row[2], Uglevodi = (decimal)row[3], Ccal = (decimal)row[4], Voda = (decimal)row[5], FoodID = (int)row[6], }); } sqlreader.Close(); return Foods; } Filling the grid from the collection
FoodProvider p = new FoodProvider(); List<Food> food = p.GetFoods(); GridOne.ItemsSource = food; During the work of the program, records are added or deleted to the second grid (the second List<Food> collection). I need to click on the button, the content of the second collection was added to the database. Tell me, please, how to insert a collection.