0
我得到了20 000個蘋果。優化創建
如何以比這更聰明的方式創建它們?
foreach (var a in apples)
{
graphClient.Cypher
.Create("(a:Apple {newApple})")
.WithParam("newApple", a)
.ExecuteWithoutResults();
}
尋找一種通用的方法來傳遞對象而不指定每個屬性。
class Fruit
{
[JsonProperty(PropertyName = "Color")]
public bool Color { get; set; }
}
class Apple : Fruit
{
[JsonProperty(PropertyName = "Variety")]
public String Variety { get; set; }
}
有了客戶端,你可以做'放鬆(蘋果,「新蘋果」)'並免除'WithParam'位。 –
Unwind似乎是要走的路,但我不斷收到'Neo4jClient.NeoException:'ParameterNotFoundException:期望一個名爲newApple''的參數,現在看不到爲什麼 – JOG
@JOG我更新了我的答案,使用'SET'而不是它在一個'CREATE'中。 –