本文整理汇总了C#中MySql.Data.Entity.Tests.testEntities.DeleteObject方法的典型用法代码示例。如果您正苦于以下问题:C# testEntities.DeleteObject方法的具体用法?C# testEntities.DeleteObject怎么用?C# testEntities.DeleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.Entity.Tests.testEntities
的用法示例。
在下文中一共展示了testEntities.DeleteObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimpleDeleteAllRows
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);
}
}
示例2: SimpleDeleteRowByParameter
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);
}
}
示例3: Delete
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);
}