本文整理汇总了C#中Address.Evict方法的典型用法代码示例。如果您正苦于以下问题:C# Address.Evict方法的具体用法?C# Address.Evict怎么用?C# Address.Evict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address.Evict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSerialiseLazyCollection
public void TestSerialiseLazyCollection()
{
Person p = BusinessObjectFactory.CreateAndFillPerson();
Address addr = new Address
{
Address1 = "12 Street",
Suburb = "Suburb",
State = "QLD",
Postcode = "1234"
};
p.Addresses.Add(addr);
PersonType ptype = new PersonType
{
ID = "contact",
Description = "General Contact"
};
ptype.Save(SaveMode.Flush);
p.ContactType = ptype;
p.Save(SaveMode.Flush);
p.Evict();
ptype.Evict();
addr.Evict();
Person loadedPerson = Person.Load(p.ID, session);
Person newPerson = loadedPerson.Clone();
loadedPerson.Evict();
//the only way so far I can see is to re-attach collections is to lock/attach the base entity
session.Lock(newPerson, NHibernate.LockMode.None);
int addrCount = newPerson.Addresses.Count;
Assert.Equal(p.ID, newPerson.ID);
Assert.Equal("contact", newPerson.ContactType.ID);
Assert.Equal(1, addrCount);
}