Select with Entity framework in N : M with multiple objects

Asked

Viewed 235 times

1

I have the following classes: Client, Contact, Phone, Campaign and Campanhacliente.

Where Campanhacliente, has a campaign, has a Customer ( who has a phone list and a contact list and who may have a phone list).

I can give a Select in Campanhacliente searching: Campaign, Client, Customer Phone List, Contact List, but not the Contacts Phone List.

return banco.CampanhasClientes.Include(x=>x.Cliente).Where(x=>x.Campanha.Id == _campanha.Id).ToList();

1 answer

2

I managed with the code below, I thought I had already tried this option, I do not know if it is the best. If there is another way better ...

return banco.CampanhasClientes.Include(x=>x.Cliente.Contatos.Select(c=>c.Telefones)).Where(x=>x.Campanha.Id == _campanha.Id).ToList();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.