首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QueryOver - JoinQueryOver问题

QueryOver - JoinQueryOver问题
EN

Stack Overflow用户
提问于 2011-04-22 08:13:02
回答 1查看 2.7K关注 0票数 3

I如何对相同的table...example使用queryover (Join)

代码语言:javascript
复制
    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");

    }

当我尝试运行时,我得到了路径重复的消息。我正在使用别名,对吗?什么问题?有理想吗?异常为“重复关联路径”

EN

回答 1

Stack Overflow用户

发布于 2011-04-23 09:47:24

我设法用LINQ to NHibernate解决了.下面是所有人的例子……

代码语言:javascript
复制
  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...see你

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5751123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档