本文整理汇总了C#中Role.UpdateValue方法的典型用法代码示例。如果您正苦于以下问题:C# Role.UpdateValue方法的具体用法?C# Role.UpdateValue怎么用?C# Role.UpdateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role.UpdateValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_persist_Audit_Role
public void should_persist_Audit_Role()
{
var auditRepo = new Repository<AuditLog>(Session);
var roleId = Guid.Parse("7C270960-0C16-4812-9CEF-275EA308A1AD");
// create the role
Session.BeginTransaction();
var roleRepo = new Repository<Role>(Session);
var role = new Role("TestRole " + roleId) {Id = roleId};
roleRepo.SaveOrUpdate(role);
Session.Transaction.Commit();
Session.Evict(role);
// assert exists in the audit log
var exists = auditRepo.Where(a => a.RecordId == roleId && a.CommitVersion.Value == 1 && a.EventType == "A" && a.EntityName == "Role");
//Assert.True(exists.Any());
// Update
Session = null;
Session = Container.Resolve<ISessionFactory>().OpenSession();
// fine the role and modify the role
Session.BeginTransaction();
roleRepo = new Repository<Role>(Session);
role = roleRepo.Get(roleId);
role.UpdateValue("TestRoleX");
Session.Transaction.Commit();
Session.Evict(role);
auditRepo = new Repository<AuditLog>(Session);
exists = auditRepo.Where(a => a.RecordId == roleId && a.CommitVersion.Value == 2 && a.EventType == "M" && a.EntityName == "Role");
//Assert.True(exists.Any());
// delete
Session = null;
Session = Container.Resolve<ISessionFactory>().OpenSession();
roleRepo = new Repository<Role>(Session);
role = roleRepo.Get(roleId);
Session.BeginTransaction();
roleRepo.Delete(role);
Session.Transaction.Commit();
auditRepo = new Repository<AuditLog>(Session);
exists = auditRepo.Where(a => a.RecordId == roleId && a.CommitVersion.Value == 3 && a.EventType == "D" && a.EntityName == "Role");
}