0

I have one table which is, for example, User. Now, In my table Books, I need to map two user fields

public User Wants {get; set;}
public User Read {get; set;}

How to map this? (Older version of fluentnhibernate and automapping doesn't work in this case) Generally, answer needs to work with automapping, because all entities in application are using automapping.

Haris Bašić
  • 1,383
  • 2
  • 12
  • 21

1 Answers1

0

I think it is straight-forward.

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()
            ;
        ;
granadaCoder
  • 26,328
  • 10
  • 113
  • 146