C# Dex图形数据库检索所有节点和边

C# Dex图形数据库检索所有节点和边,c#,graph-databases,C#,Graph Databases,我知道如何将图形数据库输出到文件(如GraphML文件),但我更愿意遍历节点并将它们作为C#对象,因为我需要在其他地方使用它们 大概是这样的: var it = graph.GetNodeIterator(); while (it.HasNext()) { var node = new MyNodeObject(); //get attributes or whatever nodeList.Add(node); } //nodeList now contains all

我知道如何将图形数据库输出到文件(如GraphML文件),但我更愿意遍历节点并将它们作为C#对象,因为我需要在其他地方使用它们

大概是这样的:

var it = graph.GetNodeIterator();
while (it.HasNext()) {
    var node = new MyNodeObject();
    //get attributes or whatever
    nodeList.Add(node);
}
//nodeList now contains all nodes in a List

我找不到一个方便的方法来做这件事,而且Dex文档也没有什么帮助。显然,Dex有一些方法可以做到这一点,因为我可以很容易地导出到GraphML,但我不想导出到GraphML,然后将GraphML解析为C#对象。

以下是我的方法,但不确定这是否是最好的方法:

//find the type(s) youre looking for based on how you assigned
//them in the first place. you may already know.
var typeIt = graph.FindTypes().Iterator();
while (typeIt.HasNext()) {
   //find your types if you dont know
}

//select the types you want. lets say all of your nodes have one of two types,
//which map to attributes 4 and 3.
var select = graph.Select(4);
//union them
select.Union(graph.Select(3));
//start to iterate
var it = select.Iterator();
while (it.HasNext()) {
    var next = it.Next();
    //map to your own objects using next
}