asp.net mvc 3 - Problems with Linq(join) -


i writting query linq(follow code bellow). looking data db.imovel , each 1 bring picture nested db.fotoimovel. keep in mind may have more 1 picture each db.imovel data.

the issue when run, returns me pictures same db.imovel data in of them.

it works me if return db.imovel data one(may first picture) db.fotoimovel.

code:

var retorno = (from c in db.fotoimovel                     join p in db.imovel on c.idimovel equals p.idimovel                     p.metragemimovel >= metragem1 && p.metragemimovel <= metragem2 &&                     p.statusimovel == opcao &&                      ((string.isnullorempty(bairro)) || p.bairroimovel == bairro) &&                     ((imovel == null) || (p.tipoimovel == imovel)) &&                     ((carros == null) || (p.qtdvagagaragemimovel == carros)) &&                     ((quartos == null) || (p.qtdquartoimovel == quartos))                     select new dadosimovel                     {                         id = p.idimovel,                         titulo = p.tituloimovel,                         descricao = p.descricaoimovel,                         foto = c.nomefotoimovel,                         tipoimovel = p.tipoimovel,                         endereco = p.enderecoimovel,                         complemento = p.complementoimovel,                         bairro = p.bairroimovel,                         cidade = p.cidadeimovel,                         estado = p.estadoimovel,                         cep = p.cepimovel,                         metragemimovel = p.metragemimovel,                         qtdcomodoimovel = p.qtdcomodoimovel,                         qtdquartoimovel = p.qtdquartoimovel,                         qtdbanheiroimovel = p.qtdbanheiroimovel,                         qtdvagagaragemimovel = p.qtdvagagaragemimovel,                         qtdandarimovel = p.qtdandarimovel,                         status = p.statusimovel,                         ativo = p.ativoimovel                     }).distinct().tolist(); 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -