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

    } 

當我嘗試運行我得到的路徑被複制的消息。我使用別名是否正確?什麼問題? havy的理想?例外的是

回答

2

我設法與LINQ NHibernate的解決「重複協會路徑」 ......還有所有的例子...

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

現在我可以睡多一點,直到...... ehehehe ......看你