在Neo4j v1.9.x下,我使用了以下类型的代码.
private Category CreateNodeCategory(Category cat)
{
var node = client.Create(cat,
new IRelationshipAllowingParticipantNode<Category>[0],
new[]
{
new IndexEntry(NeoConst.IDX_Category)
{
{ NeoConst.PRP_Name, cat.Name },
{ NeoConst.PRP_Guid, cat.Nguid.ToString() }
}
});
cat.Nid = node.Id;
client.Update<Category>(node, cat);
return cat;
}
Run Code Online (Sandbox Code Playgroud)
原因是节点ID是自动生成的,我可以稍后使用它来快速查找,在其他查询中启动位等.如下所示:
private Node<Category> CategoryGet(long nodeId)
{
return client.Get<Category>((NodeReference<Category>)nodeId);
}
Run Code Online (Sandbox Code Playgroud)
这使得以下看起来效果很好.
public Category CategoryAdd(Category cat)
{
cat = CategoryFind(cat);
if (cat.Nid != 0) { return cat; }
return CreateNodeCategory(cat);
}
public Category CategoryFind(Category cat)
{
if (cat.Nid != 0) { return cat; }
var node …
Run Code Online (Sandbox Code Playgroud) 根据TryF#.org网站,此功能将返回输入数字的四倍.
let quadruple x =
let double x = x * 2
double(double(x))
Run Code Online (Sandbox Code Playgroud)
谁能解释为什么我将其解释如下?Quadruple不执行任何突变或多次调用.
function quadruple(x)
return function double(x)
return x * 2
Run Code Online (Sandbox Code Playgroud)
或C#
int a(int x) { return b(x); }
int b(int x) { return x * 2; }
Run Code Online (Sandbox Code Playgroud)