本文整理汇总了C#中TestData.Cleanup方法的典型用法代码示例。如果您正苦于以下问题:C# TestData.Cleanup方法的具体用法?C# TestData.Cleanup怎么用?C# TestData.Cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestData
的用法示例。
在下文中一共展示了TestData.Cleanup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithClauseFailsWithFetch
public void WithClauseFailsWithFetch()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction txn = s.BeginTransaction();
Assert.Throws<SemanticException>(
() =>
s.CreateQuery("from Animal a inner join fetch a.offspring as o with o.bodyWeight = :someLimit").SetDouble(
"someLimit", 1).List(), "ad-hoc on clause allowed with fetched association");
txn.Commit();
s.Close();
data.Cleanup();
}
示例2: SimpleInsert
public void SimpleInsert()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
s.CreateQuery("insert into Pickup (id, Vin, Owner) select id, Vin, Owner from Car").ExecuteUpdate();
t.Commit();
t = s.BeginTransaction();
s.CreateQuery("delete Vehicle").ExecuteUpdate();
t.Commit();
s.Close();
data.Cleanup();
}
示例3: InsertWithManyToOne
public void InsertWithManyToOne()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
s.CreateQuery(
"insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human").
ExecuteUpdate();
t.Commit();
t = s.BeginTransaction();
t.Commit();
s.Close();
data.Cleanup();
}
示例4: DeleteUnionSubclassAbstractRoot
public void DeleteUnionSubclassAbstractRoot()
{
var data = new TestData(this);
data.Prepare();
// These should reach out into *all* subclass tables...
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("delete Vehicle where Owner = :owner").SetString("owner", "Steve").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "incorrect restricted update count");
count = s.CreateQuery("delete Vehicle").ExecuteUpdate();
Assert.That(count, Is.EqualTo(3), "incorrect update count");
t.Commit();
s.Close();
data.Cleanup();
}
示例5: DeleteOnMappedJoin
public void DeleteOnMappedJoin()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count =
s.CreateQuery("delete Joiner where joinedName = :joinedName").SetString("joinedName", "joined-name").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined class");
t.Commit();
s.Close();
data.Cleanup();
}
示例6: InsertWithMismatchedTypes
public void InsertWithMismatchedTypes()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
Assert.Throws<QueryException>(
() => s.CreateQuery("insert into Pickup (Owner, Vin, id) select id, Vin, Owner from Car").ExecuteUpdate(),
"mismatched types did not error");
t.Commit();
t = s.BeginTransaction();
s.CreateQuery("delete Vehicle").ExecuteUpdate();
t.Commit();
s.Close();
data.Cleanup();
}
示例7: DeleteOnJoinedSubclass
public void DeleteOnJoinedSubclass()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("delete Mammal where bodyWeight > 150").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass");
count = s.CreateQuery("delete Mammal").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass");
count = s.CreateQuery("delete SubMulti").ExecuteUpdate();
Assert.That(count, Is.EqualTo(0), "Incorrect deletion count on joined subclass");
t.Commit();
s.Close();
data.Cleanup();
}
示例8: DeleteOnDiscriminatorSubclass
public void DeleteOnDiscriminatorSubclass()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("delete PettingZoo").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count");
count = s.CreateQuery("delete Zoo").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count");
t.Commit();
s.Close();
data.Cleanup();
}
示例9: InsertAcrossMappedJoinFails
public void InsertAcrossMappedJoinFails()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
Assert.Throws<QueryException>(
() => s.CreateQuery("insert into Joiner (name, joinedName) select vin, owner from Car").ExecuteUpdate(),
"mapped-join insertion did not error");
t.Commit();
t = s.BeginTransaction();
s.CreateQuery("delete Joiner").ExecuteUpdate();
s.CreateQuery("delete Vehicle").ExecuteUpdate();
t.Commit();
s.Close();
data.Cleanup();
}
示例10: UpdateOnMammal
public void UpdateOnMammal()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("update Mammal set description = description").ExecuteUpdate();
Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");
count = s.CreateQuery("update Mammal set bodyWeight = 25").ExecuteUpdate();
Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");
if (! (Dialect is MySQLDialect))
{
// MySQL does not support (even un-correlated) subqueries against the update-mutating table
count = s.CreateQuery("update Mammal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate();
Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");
}
t.Commit();
s.Close();
data.Cleanup();
}
示例11: UpdateMultiplePropertyOnAnimal
public void UpdateMultiplePropertyOnAnimal()
{
var data = new TestData(this);
data.Prepare();
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
int count =
s.CreateQuery("update Animal set description = :newDesc, bodyWeight = :w1 where description = :desc")
.SetString("desc", data.Polliwog.Description)
.SetString("newDesc", "Tadpole")
.SetSingle("w1", 3)
.ExecuteUpdate();
Assert.That(count, Is.EqualTo(1));
t.Commit();
}
using (ISession s = OpenSession())
using (s.BeginTransaction())
{
var tadpole = s.Get<Animal>(data.Polliwog.Id);
Assert.That(tadpole.Description, Is.EqualTo("Tadpole"));
Assert.That(tadpole.BodyWeight, Is.EqualTo(3));
}
data.Cleanup();
}
示例12: UpdateOnAnimal
public void UpdateOnAnimal()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count =
s.CreateQuery("update Animal set description = description where description = :desc")
.SetString("desc", data.Frog.Description)
.ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect entity-updated count");
count =
s.CreateQuery("update Animal set description = :newDesc where description = :desc")
.SetString("desc",data.Polliwog.Description)
.SetString("newDesc", "Tadpole")
.ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect entity-updated count");
var tadpole = s.Load<Animal>(data.Polliwog.Id);
Assert.That(tadpole.Description, Is.EqualTo("Tadpole"), "Update did not take effect");
count =
s.CreateQuery("update Animal set bodyWeight = bodyWeight + :w1 + :w2")
.SetSingle("w1", 1)
.SetSingle("w2", 2)
.ExecuteUpdate();
Assert.That(count, Is.EqualTo(6), "incorrect count on 'complex' update assignment");
if (! (Dialect is MySQLDialect))
{
// MySQL does not support (even un-correlated) subqueries against the update-mutating table
s.CreateQuery("update Animal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate();
}
t.Commit();
s.Close();
data.Cleanup();
}
示例13: UpdateOnDiscriminatorSubclass
public void UpdateOnDiscriminatorSubclass()
{
var data = new TestData(this);
data.Prepare();
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("update PettingZoo set name = name").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");
t.Rollback();
t = s.BeginTransaction();
count =
s.CreateQuery("update PettingZoo pz set pz.name = pz.name where pz.id = :id").SetInt64("id", data.PettingZoo.Id).
ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");
t.Rollback();
t = s.BeginTransaction();
count = s.CreateQuery("update Zoo as z set z.name = z.name").ExecuteUpdate();
Assert.That(count, Is.EqualTo(2), "Incorrect discrim subclass update count");
t.Rollback();
t = s.BeginTransaction();
// TODO : not so sure this should be allowed. Seems to me that if they specify an alias,
// property-refs should be required to be qualified.
count = s.CreateQuery("update Zoo as z set name = name where id = :id").SetInt64("id", data.Zoo.Id).ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");
t.Commit();
s.Close();
data.Cleanup();
}
示例14: DeleteUnionSubclassLeafSubclass
public void DeleteUnionSubclassLeafSubclass()
{
var data = new TestData(this);
data.Prepare();
// These should only affect the given table
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("delete Car where Owner = :owner").SetString("owner", "Kirsten").ExecuteUpdate();
Assert.That(count, Is.EqualTo(1), "incorrect restricted update count");
count = s.CreateQuery("delete Car").ExecuteUpdate();
Assert.That(count, Is.EqualTo(0), "incorrect update count");
t.Commit();
s.Close();
data.Cleanup();
}
示例15: UpdateSetNullUnionSubclass
public void UpdateSetNullUnionSubclass()
{
var data = new TestData(this);
data.Prepare();
// These should reach out into *all* subclass tables...
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
int count = s.CreateQuery("update Vehicle set Owner = 'Steve'").ExecuteUpdate();
Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");
count = s.CreateQuery("update Vehicle set Owner = null where Owner = 'Steve'").ExecuteUpdate();
Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");
count = s.CreateQuery("delete Vehicle where Owner is null").ExecuteUpdate();
Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");
t.Commit();
s.Close();
data.Cleanup();
}