public virtual User ReturnUser() { User user = new User(); user.ID = Guid.NewGuid(); user.Code = "XT-001"; user.Address = "SuiZ"; user.Amount = decimal.Parse("121.00"); user.Birthday = DateTime.Now; user.CreatedBy = "DS"; user.CreatedOn = DateTime.Now; user.Disabled = false; user.Gender = true; user.Names = "ZS"; user.NativePlace = "han"; user.PostCode = "441309"; user.Price = decimal.Parse("12.10"); user.Quantity = decimal.Parse("10.00"); user.SumTotal = 10; user.SysVersion = 1; user.Telphone = "131589461"; user.UpdatedBy = "ZL"; user.UpdatedOn = DateTime.Now; user.UserAddress = "UserSuiz"; user.UserAmount = decimal.Parse("225.00"); user.UserBirthday = DateTime.Now; user.UserCode = "UserXT-001"; user.UserCreateBy = "UserDS"; user.UserCreateOn = DateTime.Now; user.UserDisabled = true; user.UserGender = false; user.UserID = Guid.NewGuid(); ; user.UserName = "******"; user.UserNativePlace = "Userhan"; user.UserPostCode = "User441309"; user.UserPrice = decimal.Parse("1.50"); user.UserQuantity = decimal.Parse("150.00"); user.UserSumTotal = 12; user.UserTelphone = "User131589461"; user.UserUpdateBy = "UserZL"; user.UserUpdateOn = DateTime.Now; return user; }
public virtual UserDTO ToDTO(User be) { UserDTO dto = DTOConvert.ToDTO<UserDTO>(be); return dto; }
public virtual UserDTO TransitiontoDto(User be) { Mapper.CreateMap<User, UserDTO>(); UserDTO dto = (UserDTO)Mapper.Map<User, UserDTO>(be); return dto; }
public virtual User ToBE(UserDTO dto) { User user = new User(); user.ID = dto.ID; user.Code = dto.Code; user.Address = dto.Address; user.Amount = dto.Amount; user.Birthday = dto.Birthday; user.CreatedBy = dto.CreatedBy; user.CreatedOn = dto.CreatedOn; user.Disabled = dto.Disabled; user.Gender = dto.Gender; user.Names = dto.Names; user.NativePlace = dto.NativePlace; user.PostCode = dto.PostCode; user.Price = dto.Price; user.Quantity = dto.Quantity; user.SumTotal = dto.SumTotal; user.SysVersion = dto.SysVersion; user.Telphone = dto.Telphone; user.UpdatedBy = dto.UpdatedBy; user.UpdatedOn = dto.UpdatedOn; user.UserAddress = dto.UserAddress; user.UserAmount = dto.UserAmount; user.UserBirthday = dto.UserBirthday; user.UserCode = dto.UserCode; user.UserCreateBy = dto.UserCreateBy; user.UserCreateOn = dto.UserCreateOn; user.UserDisabled = dto.UserDisabled; user.UserGender = dto.UserGender; user.UserID = dto.UserID; user.UserName = dto.UserName; user.UserNativePlace = dto.UserNativePlace; user.UserPostCode = dto.UserPostCode; user.UserPrice = dto.UserPrice; user.UserQuantity = dto.UserQuantity; user.UserSumTotal = dto.UserSumTotal; user.UserTelphone = dto.UserTelphone; user.UserUpdateBy = dto.UserUpdateBy; user.UserUpdateOn = dto.UserUpdateOn; return user; }
public virtual UserDTO ToDTO(User user) { UserDTO dto = new UserDTO(); dto.ID = user.ID; dto.Code = user.Code; dto.Address = user.Address; dto.Amount = user.Amount; dto.Birthday = user.Birthday; dto.CreatedBy = user.CreatedBy; dto.CreatedOn = user.CreatedOn; dto.Disabled = user.Disabled; dto.Gender = user.Gender; dto.Names = user.Names; dto.NativePlace = user.NativePlace; dto.PostCode = user.PostCode; dto.Price = user.Price; dto.Quantity = user.Quantity; dto.SumTotal = user.SumTotal; dto.SysVersion = user.SysVersion; dto.Telphone = user.Telphone; dto.UpdatedBy = user.UpdatedBy; dto.UpdatedOn = user.UpdatedOn; dto.UserAddress = user.UserAddress; dto.UserAmount = user.UserAmount; dto.UserBirthday = user.UserBirthday; dto.UserCode = user.UserCode; dto.UserCreateBy = user.UserCreateBy; dto.UserCreateOn = user.UserCreateOn; dto.UserDisabled = user.UserDisabled; dto.UserGender = user.UserGender; dto.UserID = user.UserID; dto.UserName = user.UserName; dto.UserNativePlace = user.UserNativePlace; dto.UserPostCode = user.UserPostCode; dto.UserPrice = user.UserPrice; dto.UserQuantity = user.UserQuantity; dto.UserSumTotal = user.UserSumTotal; dto.UserTelphone = user.UserTelphone; dto.UserUpdateBy = user.UserUpdateBy; dto.UserUpdateOn = user.UserUpdateOn; return dto; }
/// <summary> /// 转换多次TODTO通过一一赋值 /// </summary> private void BatchDTOToDTOFromUserDTO() { for (int i = 0; i < ITERATION; i++) { User user = new User(); User be = user.ReturnUser(); UserDTO userDTO = new UserDTO(); UserDTO dto = userDTO.ToDTO(be); } }
public void AutoMapperTest() { User target = new User(); // TODO: 初始化为适当的值 User user = target.ReturnUser(); // TODO: 初始化为适当的值 UserDTO dto = target.TransitiontoDto(user); }
/// <summary> /// 转换多次TOBE通过一一赋值 /// </summary> private void BatchDTOToBEFromUserDTO() { for (int i = 0; i < ITERATION; i++) { User user = new User(); UserDTO dto = user.ReturnUserDTO(); user = dto.ToBE(dto); } }
/// <summary> /// 转换多次AutoMapper赋值 /// </summary> private void BatchAutoToDTOMapper() { for (int i = 0; i < ITERATION; i++) { User target = new User(); // TODO: 初始化为适当的值 User user = target.ReturnUser(); // TODO: 初始化为适当的值 UserDTO dto = target.TransitiontoDto(user); } }
/// <summary> /// 转换多次AutoMapper赋值 /// </summary> private void BatchAutoToBEMapper() { for (int i = 0; i < ITERATION; i++) { User target = new User(); // TODO: 初始化为适当的值 UserDTO dto = target.ReturnUserDTO(); // TODO: 初始化为适当的值 User be = target.TransitiontoBE(dto); } }
public void DTOToBECeshi() { User target = new User(); // TODO: 初始化为适当的值 UserDTO dto = target.ReturnUserDTO(); // TODO: 初始化为适当的值 //Order expected = null; // TODO: 初始化为适当的值 User actual; actual = target.ToBE(dto); Assert.AreEqual(actual.Birthday, dto.Birthday); Assert.AreEqual(actual.ID, dto.ID); Assert.AreEqual(actual.CreatedBy, dto.CreatedBy); Assert.AreEqual(actual.CreatedOn, dto.CreatedOn); }
public void BEToDTOCeshi() { User target = new User(); // TODO: 初始化为适当的值 User be = target.ReturnUser(); // TODO: 初始化为适当的值 //Order expected = null; // TODO: 初始化为适当的值 UserDTO actual; actual = target.ToDTO(be); Assert.AreEqual(actual.Birthday, be.Birthday); Assert.AreEqual(actual.ID, be.ID); Assert.AreEqual(actual.CreatedBy, be.CreatedBy); Assert.AreEqual(actual.CreatedOn, be.CreatedOn); }