Entity Linq query in many-to-many relationship

1

I inherited a bank that is untouchable ... Despite having some very "strange" things. For example I have the following situation that would represent a n-n relationship but the relationship does not actually exist.

In other words, a neighborhood can have many properties and a property can ... have many neighborhoods. And to worsen the relationship between tbBairro and TbBairroImovel really does not exist.

Now I need to search the bank for a list of all the properties that are on a neighborhood list. Like this:

int[] ListaIdsBairros = { 10, 2, 37 };
imoveis = MeuContexot.tbImovel.Where(I => ListaIdsBairros.Contains(não sei o que por aqui));

I do not even know if it's possible to do this search on a single line. Will I have to loop through ListaIdsBairros by adding the return of properties to each neighborhood in a general list of properties ???

Does anyone have an idea how to do this search?

Added after ------------------------------------------ --------

Today I can only do this:

List<tbImovel> ResultImoveis = new List<tbImovel>();
        foreach (var Bairro in ListaDeIds)
        {
            List<tbImovel> Imoveis = new List<tbImovel>();
            Imoveis = ctx.tbBairroImovel.Where(bi => bi.idBairro == Bairro.idBairro).Select(bi => bi.tbImovel).ToList();
            foreach(var imovel in Imoveis)
            {
                ResultImoveis.Add(imovel);
            }
        }

But I'm trying to improve on that.

    
asked by anonymous 09.12.2017 / 18:01

0 answers