使用FluentNHibernate对同一个表的两个引用
本文关键字:两个 引用 FluentNHibernate 同一个 使用 | 更新日期: 2023-09-27 18:03:45
我有一个表,例如,User
。现在,在表Books
中,我需要映射两个用户字段
public User Wants {get; set;}
public User Read {get; set;}
如何映射这个?(旧版本的fluenthibernate和自动映射在这种情况下不起作用)一般来说,答案需要使用自动映射,因为应用程序中的所有实体都在使用自动映射。
我认为这很简单。
public class BookMap : ClassMap<Book>
{
public BookMap()
{
/* all other mapping info */
References<User>(x => x.Wants)
.Class(typeof(User))
/*.Not.Nullable() */
.Nullable()
.Column("WantsUserUUID")
.Index("IX_Book_WantsUserUUID")
.Cascade.SaveUpdate()
;
;
References<User>(x => x.Read )
.Class(typeof(User))
/*.Not.Nullable() */
.Nullable()
.Column("ReadUserUUID")
.Index("IX_Book_ReadUserUUID")
.Cascade.SaveUpdate()
;
;