Reputation: 97
How to create multiple nodes in a single transaction using neo4jClient.The Current code works fine but is a bit slower
foreach (UserInfo _ui in users)
{
client.Cypher.Create("(n:User{param})")
.WithParam("param", _ui).ExecuteWithoutResults();
}
Upvotes: 0
Views: 667
Reputation: 67044
In Cypher, you can create multiple nodes in a single transaction using a parameter that is a collection of maps. Since your users
variable already seems to be such a collection, try replacing your loop with:
client.Cypher.Create("(n:User{param})")
.WithParam("param", users).ExecuteWithoutResults();
Upvotes: 0