2017-04-10 28 views
0

獲取集合如何可以使用neo4jClient取多列數據 -Neo4jClient:C#查詢多列

情商。上鍊路

Cyper query to fetch multiple column collection

上面所示的樣品通行證集合,而不是完整的事件節點事件節點的屬性示出的例子。

我正在構建的查詢從事件節點獲取的屬性很少,並且關係中的屬性很少。

For eq。需要添加關係屬性「registerd_on」。 那麼如何傳遞多個屬性進行收集?

回答

0

這不是很好,但是如果你看看做一個集合返回什麼,你會得到一個數組數組,但是這些數組沒有屬性,所以你只能真正解析它們爲string

使用:play movies數據集爲基礎:

var query = gc.Cypher 
    .Match("(p:Person {name:'Tom Hanks'})-->(m:Movie)") 
    .With("p, collect([m.title, m.released]) as collection") 
    .Return((p, collection) => new 
    { 
     Person = p.As<Person>(), 
     Collection = Return.As<IEnumerable<IEnumerable<string>>>("collection") 

    }); 

其中Person是:

public class Person 
{ 
    public string name { get; set; } 
} 

然後,您可以訪問數據,像這樣:

foreach (var result in results) 
{ 
    Console.WriteLine($"Person: {result.Person.name}"); 
    foreach (var collection in result.Collection) 
    { 
     foreach (var item in collection) 
     { 
      Console.WriteLine($"\t{item}"); 
     } 
    } 
} 

這是不是很好:/

+0

謝謝克里斯。 已經想出了從 的答案https://github.com/Readify/Neo4jClient/issues/214 – user1872862