我正在寻找如何将对象列表(在内存中)展开到 Neo4j 4.0 中。以下是我之前使用 Neo4jClient nuget 的内容,但我不得不改用 Neo4j.Driver nuget。
Neo4jClient(旧)
graphClient.Cypher
.Unwind(towns, "tp")
.Merge("t:Town {Name: tp.Id})")
.OnCreate()
.Set("t = tp")
.ExecuteWithoutResults();
Neo4j 驱动程序(到目前为止完成)
var session = driver.AsyncSession(o => o.WithDatabase("neo4j"));
try
{
towns = towns.OrderBy(tt => tt.Id).ToList();
foreach (var t in towns.Split(5000))
{
Console.WriteLine($"Saving {t.Count:N0} of {town.Count:N0} Towns...");
**//STUCK HERE DOING UNWIND**
}
}
catch (Exception ex)
{
string error = $"ERROR (ADD TOWNS): {ex.ToString()}";
Console.WriteLine(error);
}
finally
{
await session.CloseAsync();
}