本文整理汇总了C#中Profile.IsTransient方法的典型用法代码示例。如果您正苦于以下问题:C# Profile.IsTransient方法的具体用法?C# Profile.IsTransient怎么用?C# Profile.IsTransient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile.IsTransient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveDeleteProfile
public void SaveDeleteProfile()
{
Applicant applicant = NHibernateHelper.DaoFactory.GetApplicantDao().GetById(StaticProperties.ExistingApplicantID, false);
Profile target = new Profile();
target.AssociatedApplicant = applicant; //associate with the applicant
target.Address1 = StaticProperties.TestString;
target.City = StaticProperties.TestString;
target.State = StaticProperties.TestString;
target.FirstName = StaticProperties.TestString;
target.LastName = StaticProperties.TestString;
//Validate before saving
Assert.IsTrue(ValidateBO<Profile>.isValid(target), "Target Profile not valid");
using (var ts = new TransactionScope())
{
target = NHibernateHelper.DaoFactory.GetProfileDao().Save(target); //save the target
ts.CommitTransaction();
}
this.TestContext.WriteLine("Profile created: ID={0}", target.ID);
Assert.IsNotNull(target);
Assert.IsFalse(target.IsTransient()); //make sure that target is saved to the database
Profile targetDB = NHibernateHelper.DaoFactory.GetProfileDao().GetById(target.ID, false);
Assert.IsNotNull(targetDB);
Assert.AreEqual<Profile>(target, targetDB);
//Now delete the new profile
using (var ts = new TransactionScope())
{
NHibernateHelper.DaoFactory.GetProfileDao().Delete(target);
ts.CommitTransaction();
}
//Make sure it is deleted
bool isDeleted = false;
try
{
targetDB = NHibernateHelper.DaoFactory.GetProfileDao().GetById(target.ID, false);
targetDB.IsTransient(); //check to see if its in the db
}
catch (NHibernate.ObjectNotFoundException)
{
isDeleted = true;
}
Assert.IsTrue(isDeleted);
}