【问题标题】:NHIBERNATE QUERYOVER休眠查询
【发布时间】:2011-08-09 19:47:32
【问题描述】:

嗨 如何对同一张表使用 queryover (Join)...示例

        if (!string.IsNullOrEmpty(ufResidencia))
        {
            EnderecoProspect endProspectRes =null;
            TipoEndereco tipoEndProspectRes = null;

            query
                .JoinQueryOver<EnderecoProspect>(x => x.Enderecos, () => endProspectRes)
                    .And(() => endProspectRes.Uf == ufResidencia)
                        .JoinQueryOver<TipoEndereco>(x => x.TipoEndereco, () => tipoEndProspectRes)
                            .And(() => tipoEndProspectRes.Descricao != "Fazenda");
        }

        if (!string.IsNullOrEmpty(ufFazenda))
        {
            EnderecoProspect endProspectFaz = null;
            TipoEndereco tipoEndProspectFaz = null;

            query
                .JoinQueryOver<EnderecoProspect>(x => x.Enderecos, () => endProspectFaz)
                    .And(() => endProspectFaz.Uf == ufFazenda)
                        .JoinQueryOver<TipoEndereco>(x => x.TipoEndereco, () => tipoEndProspectFaz)
                            .And(() => tipoEndProspectFaz.Descricao == "Fazenda");

        }

当我尝试运行时,我收到路径重复的消息。

【问题讨论】:

    标签: nhibernate fluent-nhibernate queryover


    【解决方案1】:

    尝试使用别名

    EnderecoProspect additionalProspect = null;
    
    query
       .JoinQueryOver<EndercoProspect>(x => x.Endercos, () => additionalProspect)...
    

    【讨论】:

      猜你喜欢
      • 2021-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-24
      相关资源
      最近更新 更多