本文整理汇总了C#中TestDataConnection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# TestDataConnection.Insert方法的具体用法?C# TestDataConnection.Insert怎么用?C# TestDataConnection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestDataConnection
的用法示例。
在下文中一共展示了TestDataConnection.Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsJoin1
public void ContainsJoin1(string context)
{
using (var db = new TestDataConnection(context))
{
db.Child. Delete(c => c.ParentID >= 1000);
db.Parent.Delete(c => c.ParentID >= 1000);
try
{
var id = 1000;
db.Insert(new Parent { ParentID = id });
for (var i = 0; i < 3; i++)
db.Insert(new Child { ParentID = id, ChildID = 1000 + i });
var sql1 = ContainsJoin1Impl(db, new [] { 1000, 1001 });
var sql2 = ContainsJoin1Impl(db, new [] { 1002 });
Assert.That(sql1, Is.Not.EqualTo(sql2));
}
finally
{
db.Child. Delete(c => c.ParentID >= 1000);
db.Parent.Delete(c => c.ParentID >= 1000);
}
}
}
示例2: AutoRollbackTransaction
public void AutoRollbackTransaction(string context)
{
using (var db = new TestDataConnection(context))
{
db.Insert(new Parent { ParentID = 1010, Value1 = 1010 });
try
{
using (db.BeginTransaction())
{
db.Parent.Update(t => t.ParentID == 1010, t => new Parent { Value1 = 1012 });
}
var p = db.Parent.First(t => t.ParentID == 1010);
Assert.That(p.Value1, Is.Not.EqualTo(1012));
}
finally
{
db.Parent.Delete(t => t.ParentID >= 1000);
}
}
}
示例3: CommitTransaction
public void CommitTransaction()
{
using (var db = new TestDataConnection())
{
db.Insert(new Parent { ParentID = 1010, Value1 = 1010 });
try
{
using (var tr = db.BeginTransaction())
{
db.Parent.Update(t => t.ParentID == 1010, t => new Parent { Value1 = 1011 });
tr.Commit();
}
var p = db.Parent.First(t => t.ParentID == 1010);
Assert.That(p.Value1, Is.EqualTo(1011));
}
finally
{
db.Parent.Delete(t => t.ParentID >= 1000);
}
}
}
示例4: MyType3
public void MyType3()
{
using (var db = new TestDataConnection().AddMappingSchema(_myMappingSchema) as TestDataConnection)
{
try
{
db.Insert(new MyParent { ParentID = new MyInt { MyValue = 1001 }, Value1 = 1001 });
}
finally
{
db.Parent.Delete(p => p.ParentID >= 1000);
}
}
}