コード例 #1
0
        private static DbDataGraph GetDbModelGraph(DbInfoSimple dbInfo)
        {
            var dbGraph = new DbDataGraph();

            // add vertexes (tables)
            var tables = dbInfo.ListTableNames();

            dbGraph.AddVertexRange(tables.Select(t => new DbDataVertex(tableName: t)));

            // add edges (FKs)
            var vertices = dbGraph.Vertices.ToDictionary(v => v.TableName, v => v);

            foreach (var vertice in dbGraph.Vertices)
            {
                var tableFkEdgess = dbInfo.ReadTableFks(vertice.TableName)
                                    .Select(fk => new DbDataEdge(vertices[fk.ToString()], vertice));
                dbGraph.AddEdgeRange(tableFkEdgess);
            }

            return(dbGraph);
        }
コード例 #2
0
        public static BidirectionalGraph <DataVertex, DataEdge> Convert(DbDataGraph oldGraph)
        {
            var dataVertices = oldGraph.Vertices.ToDictionary(v => v, v => new DataVertex(v.ToString()));

            return(oldGraph.Convert(vertexMapperFunc: i => dataVertices[i], edgeMapperFunc: e => new DataEdge(dataVertices[e.Source], dataVertices[e.Target])));
        }