Fluent NHibernate 的密码确认字段
我是 NHibernate 的新手,正在尝试构建我的第一个简单网站。我想要一个带有密码和确认密码字段的用户注册屏幕。
我的 User
业务对象中有这些字段,但无法确定要使用哪个映射,以便从 Password
加载 ConfirmPassword
字段> 加载User
时的数据库字段,但在保存对象时被忽略。
这可能吗?
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 object is saved.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想说这不是最好的方法。而是创建两个类。一种是 User - 来自域的实体,一种是 UserViewModel - 通常是普通的 DTO。保存或检索 User 对象时,将其值映射到 ViewModel。您可以手动执行或使用 AutoMapper 库。所以User只有Password,而ViewModel有这两个属性。
但如果您需要这个或类似的东西,在您的映射中写
这应该可以工作。
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
This should work.