简体   繁体   中英

NHIBERNATE QUERYOVER

Hi How to use queryover (Join) for same table...example

        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");

        }

When I try to run I get the message that the path is duplicated.

Try using an alias

EnderecoProspect additionalProspect = null;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM