public void SimpleDeleteAllRows() { using (testEntities context = new testEntities()) { foreach (Toy t in context.Toys) context.DeleteObject(t); context.SaveChanges(); EntityConnection ec = context.Connection as EntityConnection; MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM toys", (MySqlConnection)ec.StoreConnection); DataTable dt = new DataTable(); da.Fill(dt); Assert.AreEqual(0, dt.Rows.Count); } }
public void SimpleDeleteRowByParameter() { using (testEntities context = new testEntities()) { MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM toys WHERE minage=3", conn); DataTable dt = new DataTable(); da.Fill(dt); Assert.IsTrue(dt.Rows.Count > 0); ObjectQuery<Toy> toys = context.Toys.Where("it.MinAge = @age", new ObjectParameter("age", 3)); foreach (Toy t in toys) context.DeleteObject(t); context.SaveChanges(); dt.Clear(); da.Fill(dt); Assert.AreEqual(0, dt.Rows.Count); } }
public void Delete() { using (testEntities context = new testEntities()) { foreach (Book b in context.Books) context.DeleteObject(b); context.SaveChanges(); } MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Books", conn); DataTable dt = new DataTable(); da.Fill(dt); Assert.AreEqual(0, dt.Rows.Count); }