3

내가 어떻게 같은 테이블 queryover 사용 (가입)하는 ... 예를QueryOver - JoinQueryOver 문제

if (!string.IsNullOrEmpty(ufResidencia) || 
     !string.IsNullOrEmpty(cidadeResidencia)) 
    { 
     EnderecoProspect endPros = null; 
     TipoEndereco tipoEnd = null; 
     query 
      .JoinQueryOver<EnderecoProspect>(x => x.Enderecos,()=> endPros) 
       .And(()=> endPros.Uf ==ufResidencia) 
        .JoinQueryOver<TipoEndereco>(x => x.TipoEndereco,()=> tipoEnd) 
         .And(()=> tipoEnd.Descricao != "Fazenda"); 
    } 

    if (!string.IsNullOrEmpty(ufFazenda) || 
     !string.IsNullOrEmpty(cidadeFazenda)) 
    { 
     EnderecoProspect endPros1 = null; 
     TipoEndereco tipoEnd1 = null; 
     query 
      .JoinQueryOver<EnderecoProspect>(x => x.Enderecos,()=> endPros1) 
       .And(()=> endPros1.Uf ==ufFazenda) 
        .JoinQueryOver<TipoEndereco>(x => x.TipoEndereco,()=> tipoEnd1) 
         .And(()=> tipoEnd1.Descricao == "Fazenda"); 

    } 

내가 경로가 중복된다는 메시지가 실행 해보십시오. 내가 별칭을 올바르게 사용하고 있습니까? 무슨 문제? 하비 이상? 예외가 나는 자 NHibernate에 LINQ와 함께 해결하기 위해 운영

답변

2

"중복 연결 경로"입니다 ... ehehehe ...

이제
var q = 
      from c in Context.Query<Prospect>() 
      join o in Context.Query<EnderecoProspect>() on c.Identificacao equals     o.Prospect.Identificacao 
      join e in Context.Query<TipoEndereco>() on o.TipoEndereco.Identificacao equals e.Identificacao 
      join a in Context.Query<EnderecoProspect>() on c.Identificacao equals a.Prospect.Identificacao 
      join b in Context.Query<TipoEndereco>() on a.TipoEndereco.Identificacao equals b.Identificacao 
      where (
        (
         (o.Uf == ufFazenda || ufFazenda == null) && 
         (o.Cidade == cidadeFazenda || cidadeFazenda == null) 
        ) && e.Descricao == "Fazenda" 
       ) 
        && 
        (
        (
         (a.Uf == ufResidencia || ufResidencia == null) && 
         (a.Cidade == cidadeResidencia || cidadeResidencia == null) 
        ) && b.Descricao != "Fazenda" 
       ) 

내가 때까지 조금 더 잘 수 ... 모든 예제가있다 ... 보자.