Select with entity framework in N: M with multiple objects

1

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

Where CampaignCustomer, has a campaign, has a Client (who has a phone list and a contact list and who may have a phone list).

I can give a Select in the Customer Campaign that you are looking for: 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();
    
asked by anonymous 10.02.2018 / 01:52

1 answer

2

I managed with the code below, I thought I had tried this option, I do not know if it is the best. If you have a better way ...

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