Optimal LinqToSql GroupBy query, in 1:m relationship
I have two database tables (connected with relation 1:m):
Location (locId, locName)
1, USA
2, Germany
3, Spain
Sublocations (subLocId, subLocName, locId)
1, Denver, 1
2, Detroit, 1
3, New York, 1
4, Hamburg, 2
5, Berlin, 2
6, Munich, 2
7, Madrid, 3
8, Barcelona, 3
9, Valencia, 3
With using Linq to Sql, I need to fill the LocationDto, like this:
LocationDto (locId, subLocId, name)
1, null, USA
1, 1, Denver
1, 2, Detroit
1, 3, New York
2,null, Germany
2, 4, Hamburg
2, 5, Berlin
2, 6, Munich
3,null, Spain
3, 7, Madrid
3, 8, Barcelona
3, 9, Valencia
No comments:
Post a Comment