本文整理汇总了C#中UserRepository.SaveOrUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.SaveOrUpdate方法的具体用法?C# UserRepository.SaveOrUpdate怎么用?C# UserRepository.SaveOrUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.SaveOrUpdate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: shouldHaveCreateMethod
public void shouldHaveCreateMethod()
{
var userRepository = new UserRepository();
var user = userRepository.SaveOrUpdate(new User("myUser"));
Assert.AreEqual(1, user.Id);
}
示例2: LoadTestData
protected override void LoadTestData()
{
var userRepository = new UserRepository();
userA = userRepository.SaveOrUpdate(new User());
userProfileRepository = new UserProfileRepository();
userProfileRepository.SaveOrUpdate(new UserProfile() { User = userA });
NHibernateSession.Current.Flush();
}
示例3: CreateUser
//[Test]
//public Department CreateDepartment()
//{
// IDepartmentRepository departmentRepository = new DepartmentRepository();
// var deppart = departmentRepository.SaveOrUpdate(new Department()
// {
// Name = "内分泌科"
// });
// departmentRepository.SaveOrUpdate(new Department()
// {
// Parent = deppart,
// Name = "内分泌一组"
// });
// return departmentRepository.SaveOrUpdate(new Department()
// {
// Parent = deppart,
// Name = "内分泌二组"
// });
//}
public void CreateUser()
{
IUserRepository userRepository = new UserRepository();
User user = new User();
user.LoginName = "houck";
user.RealName = "程康";
user.NickName = "康康";
user.Gender = Gender.男;
user.Mobile = "18653170063";
user.Enabled = Enabled.启用;
user.Note = "系统自动添加";
user.CreateTime = DateTime.Now;
MembershipUser membershipuser = Membership.CreateUser(user.LoginName, "123");
user.MemberShipId = (Guid)membershipuser.ProviderUserKey;
userRepository.SaveOrUpdate(user);
}
示例4: TestAdd
public void TestAdd()
{
// Arrange
IUserRepository repository = new UserRepository();
User u = new User
{
Username = "test",
Password = "Test123",
Firstname = "Hans",
Lastname = "Muster",
EMail = "[email protected]"
};
// Act
repository.SaveOrUpdate(u);
// Assert
User user = repository.GetByUsername(u.Username);
Assert.IsNotNull(user);
Assert.AreEqual(u.Username, user.Username);
Assert.AreEqual(u.Firstname, user.Firstname);
Assert.AreEqual(u.Lastname, user.Lastname);
Assert.AreEqual(u.EMail, user.EMail);
}