I have a many-to-many table that correlates an object to a place, for example
1 1
2 1
4 3
5 9
6 2
I have a different table of many places, and there are several tables linked into it by foreign key like address book entries and history. What I need is to send a collection to my View in MVC of all the information for a place, but only if it is a place used in my many-to-many table, ie in the example places 1, 3, 9, and 2
So right now I do two queries
var places = myodataservice.Get(new QueryBuilder<MapTable>())
.Select(t => t.PlaceId)
.Distinct();
var returnable = myodataservice.Get(
new QueryBuilder<Places>(),
p => p.Address,
p => p.Address.State,
p => p.Logo
).Where(p => places.Contains(p.Id))
This is both very slow, and seems like a terrible way to run a query. Is there a better way to achieve this, in possibly a single query?