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

    } 

私はパスが重複しているというメッセージが表示されます実行してみてください。私は別名を使用して正しい?何の問題?ヘビー理想?例外は、今私はehehehe ...までもう少し眠ることができます...私はNHibernateのにLINQを解決するために管理

答えて

2

...すべてのための例がある

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

「重複アソシエーションパス」であります...あなたに会おう