mapping nhibernate parent/child relationship the 'other' way round

后端 未结 3 2051
生来不讨喜
生来不讨喜 2021-01-22 10:50

using FluentNhibernate;

I am trying to persist a seemingly simple object model:

public class Product
{
    public int Id { get; set; }
    public string          


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 11:21

    Another idea is to join and map as Component

    public class ProductMap : ClassMap
    {
        public class ProductMap()
        {
            Join("Config", join => 
            {
                join.KeyColumn("ProductId");
                join.Component(p => p.Config, c =>
                {
                    c.Map(...);
                });
            }
        }
    }
    

    Disadvantage is that you can not query Config directly, you have to query through Product

提交回复
热议问题