Password Confirmation Fields with Fluent NHibernate
I'm new to NHibernate and am trying to build my first simple website. I want a user registration screen with Password and ConfirmPassword fields.
I have these fields in my User
business object, but am having trouble working out which mapping to use so that the ConfirmPassword
field is loaded from the Password
database field when a User
is loaded, but ignored when the o开发者_Python百科bject is saved.
Is this possible?
I would say its not the best way to go. Rather create two classes. One is User - entity from domain, one is UserViewModel - usually plain DTO. When saving or retrieving User object map its values to ViewModel. You can do in manually or use AutoMapper library. So User has only Password, and ViewModel has both properties.
But if you need this or something similar, in your mapping write
mapping.Map(o => o.PasswordConfirm).Formula(" Password ");
This should work.
精彩评论