Search code examples
fluent-nhibernatefluent-nhibernate-mapping

Map a collection of custom types on fluent nhibernate


I have a Custom Type on Fluent NHibernate and I need to map it to a collection of its type, using HasMany association. However, Fluent Nhibernate doesn't let me indicate on HasMany that its about a custom type like I do in my regular types.

This is my code:

HasMany(x => x.AvailablePaymentOptions)
            .KeyColumn("OFFER_ID")
            .Cascade.None()
            .KeyNullable()
            .Not.LazyLoad();

Any thoughts?

Thanks


Solution

  • Finish not using the custom type, but instead, mapping a component:

    HasMany(x => x.AvailablePaymentOptions)
                .Table("MY_TABLE")
                .KeyColumn("MY_COLUMN")
                .Component(component =>
                               {
                                   //MAP YOUR CUSTOM TYPE HERE
                               })
                .Cascade.None()
                .KeyNullable()
                .Not.LazyLoad();