加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

Fetch.Join()不工作在Fluent NHibernate

发布时间:2020-12-12 08:49:11 所属栏目:MsSql教程 来源:网络整理
导读:我在关系的一边有以下映射覆盖: public void Override(AutoMappingItemAsmtDetailDh mapping){ mapping.HasManyWAsmtDetail(x = x.WAsmtDetails).Inverse().AsBag().Cascade.AllDeleteOrphan().Access.PascalCaseField(Prefix.Underscore).Not.LazyLoad().Fe
我在关系的一边有以下映射覆盖:
public void Override(AutoMapping<ItemAsmtDetailDh> mapping)
{
    mapping.HasMany<WAsmtDetail>(x => x.WAsmtDetails).Inverse().AsBag().Cascade.AllDeleteOrphan().Access.PascalCaseField(Prefix.Underscore).Not.LazyLoad().Fetch.Join();
}

在我的关系的另一边:

public void Override(AutoMapping<WAsmtDetail> mapping)
{
    mapping.References<ItemAsmtDetailDh>(x => x.ItemAsmtDetailDh).Not.Nullable().Not.LazyLoad().Fetch.Join();
}

当我使用ShowSql选项时,我看到它仍然为WAsmtDetails发出单独的select语句,给我可怕的“n 1选择”问题.为什么“.Not.LazyLoad().Fetch.Join()”被忽略?

注意:我使用Fluent NHibernate版本1.1,而不是版本2.1,因为较新版本的错误. (查看我的答案this question的错误详细信息.)我使用NHibernate版本2.1.2.4000.

解决方法

您最有可能以映射(如HQL或Linq)中的Fetch.Join()不受影响的方式加载数据.从NHibernate文档:

The fetch strategy defined in the mapping document affects:

  • retrieval via Get() or Load()
  • retrieval that happens implicitly when an association is navigated
  • ICriteria queries
  • HQL queries if subselect fetching is used

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读