本文整理汇总了C#中TestUser.MarkModifiedIfUnchanged方法的典型用法代码示例。如果您正苦于以下问题:C# TestUser.MarkModifiedIfUnchanged方法的具体用法?C# TestUser.MarkModifiedIfUnchanged怎么用?C# TestUser.MarkModifiedIfUnchanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUser
的用法示例。
在下文中一共展示了TestUser.MarkModifiedIfUnchanged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ET_PersistenceStatus
public void ET_PersistenceStatus()
{
var entity = new TestUser();
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.New, "刚创建的对象的状态应该是 New。");
entity.PersistenceStatus = PersistenceStatus.Unchanged;
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Unchanged);
entity.MarkModifiedIfUnchanged();
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Modified);
entity.PersistenceStatus = PersistenceStatus.Deleted;
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Deleted);
}
示例2: ET_PersistenceStatus_Delete
public void ET_PersistenceStatus_Delete()
{
var entity = new TestUser();
entity.PersistenceStatus = PersistenceStatus.Unchanged;
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Unchanged);
entity.PersistenceStatus = PersistenceStatus.Deleted;
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Deleted);
entity.RevertDeletedStatus();
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Unchanged, "之前的状态是 Unchanged");
entity.MarkModifiedIfUnchanged();
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Modified);
entity.PersistenceStatus = PersistenceStatus.Deleted;
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Deleted);
entity.RevertDeletedStatus();
Assert.IsTrue(entity.PersistenceStatus == PersistenceStatus.Modified, "之前的状态是 Modified");
}
示例3: ORM_EntityContext_Update
public void ORM_EntityContext_Update()
{
var repo = RF.Concrete<TestUserRepository>();
using (RF.TransactionScope(repo))
{
var user = new TestUser();
repo.Save(user);
using (RF.EnterEntityContext())
{
user.MarkModifiedIfUnchanged();
repo.Save(user);
var user2 = repo.GetById(user.Id);
Assert.IsTrue(user == user2, "实体上下文块内,二者应该是同一个对象。");
}
}
}