Fluent-Nhibernate References and PropertyRef Doing a Select With Lazy Load

后端 未结 2 1491
逝去的感伤
逝去的感伤 2021-01-06 13:12

I am using PropertyRef for one of my References properties. With LazyLoad() it still does a Select and loads the User ent

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-06 14:10

    I don't think this is a bug in NHibernate. It depends on your mapping.

    First, remember that the reference map will join the key (primary key and foreign key) between 2 mapping tables. To prevent SELECT + 1, just ignore the key joint.

    References(x => x.SalesPerson)
                        .LazyLoad()
                        .PropertyRef(x => x.Username)
                        WithForeignKeyName("none") //disable key join.
    

提交回复
热议问题