Paulo
Paulo

Reputation: 1

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.

Upvotes: 0

Views: 722

Answers (1)

Vadim
Vadim

Reputation: 17957

Try using an alias

EnderecoProspect additionalProspect = null;

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

Upvotes: 3

Related Questions