Sorry for this for so long, but at least I think I have all the information to understand and maybe help?
I would like to load data from my database using downloadable download.
Data is tuned in five tables, setting two levels of m: n relationships. Thus, there are three tables containing data (ordered by hierarchy from top to bottom):
CREATE TABLE [dbo].[relations](
[relation_id] [bigint] NOT NULL
)
CREATE TABLE [dbo].[ways](
[way_id] [bigint] NOT NULL
)
CREATE TABLE [dbo].[nodes](
[node_id] [bigint] NOT NULL,
[latitude] [int] NOT NULL,
[longitude] [int] NOT NULL
)
The first two really consist only of their own identifier (for binding other data that does not matter here).
Between these three data tables are two m: n tables with a sort prompt:
CREATE TABLE [dbo].[relations_ways](
[relation_id] [bigint] NOT NULL,
[way_id] [bigint] NOT NULL,
[sequence_id] [smallint] NOT NULL
)
CREATE TABLE [dbo].[ways_nodes](
[way_id] [bigint] NOT NULL,
[node_id] [bigint] NOT NULL,
[sequence_id] [smallint] NOT NULL
)
, , OpenStreetMap. Entity Framework , .
m: n . ( , EF m: n - ?)
: - .
, m: n, . .
IQueryable<relation> query = context.relations;
query = query.Where( ... ); // filters down to exactly one
query = query.Include(r => r.relation_members);
relation rel = query.SingleOrDefault();
1: n info - , . , 1: n, "".
, :
query = query.Include(r => r.relation_members.Select(rm => rm.way));
, , ?
, , node . :
foreach (relation_member rm in rel.relation_members) {
IQueryable<way_node> query = rm.way.way_nodes.AsQueryable();
query = query.Include(wn => wn.node);
query.Load();
}
1: n way_node , not node (/). , , node.
, 1 β 300 , β 2000 . , , 1 + 300 + 300 * 2000... , .
? , .
; , ?