当前位置: 首页>>代码示例>>C#>>正文


C# Profile.IsTransient方法代码示例

本文整理汇总了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);
        }
开发者ID:ucdavis,项目名称:Recruitments,代码行数:54,代码来源:ProfileTest.cs


注:本文中的Profile.IsTransient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。