本文整理汇总了C#中MySql.Data.Entity.Tests.testEntities.AddToProducts方法的典型用法代码示例。如果您正苦于以下问题:C# testEntities.AddToProducts方法的具体用法?C# testEntities.AddToProducts怎么用?C# testEntities.AddToProducts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.Entity.Tests.testEntities
的用法示例。
在下文中一共展示了testEntities.AddToProducts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanInsertRowWithDefaultTimeStamp
public void CanInsertRowWithDefaultTimeStamp()
{
using (testEntities context = new testEntities())
{
// The default timestamp is in the CreatedDate column.
Product product = new Product();
product.Name = "Coca Cola";
context.AddToProducts(product);
context.SaveChanges();
Assert.AreEqual(DateTime.Today.Day, product.CreatedDate.Day);
}
}
示例2: UpdateSimple
public void UpdateSimple()
{
using (testEntities context = new testEntities())
{
MySqlTrace.Listeners.Clear();
MySqlTrace.Switch.Level = SourceLevels.All;
GenericListener listener = new GenericListener();
MySqlTrace.Listeners.Add(listener);
Product pc = null;
try
{
pc = new Product();
pc.Name= "Acme";
context.AddToProducts(pc);
context.SaveChanges();
pc.Name = "Acme 2";
context.SaveChanges();
}
finally
{
#if CLR4
context.Products.DeleteObject(pc);
#endif
}
// Check sql
Regex rx = new Regex(@"Query Opened: (?<item>UPDATE .*)", RegexOptions.Compiled | RegexOptions.Singleline);
foreach( string s in listener.Strings )
{
Match m = rx.Match(s);
if (m.Success)
{
CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelect);
Assert.Pass();
}
}
Assert.Fail();
}
}