我创建了一个方法,它接受节点属性并更新指定节点上的这些属性,但是当它到达代码进行更新时,我得到一个System.NullReferenceException: Object reference not set to an instance of an object.
这是代码:
public NodeReference<EntityNode> GraphUpdateEntityNode(
NodeReference<EntityNode> nodeId,
string guid,
string type,
string name,
string dateTimeCreated,
string currentVersionDateTimeCreated,
int versionCount,
int currentVersion)
{
var nodeRef = (NodeReference<EntityNode>)nodeId;
GraphOperations graphOp = new GraphOperations();
graphOp.GraphGetConnection();
clientConnection.Update(nodeRef, node =>
{
node.GUID = guid;
node.Type = type;
node.Name = name;
node.CurrentVersion = currentVersion;
node.DateTimeCreated = dateTimeCreated;
node.CurrentVersionDateTimeCreated = currentVersionDateTimeCreated;
node.VersionCount = versionCount;
});
return nodeRef.Id;
}
我在这里想念什么?我是否必须通过这样做再次获取节点的引用,var nodeRef = (NodeReference<EntityNode>)nodeId;
因为我已经将它作为方法的参数传递了?我必须 clientConnection.Connect
在更新节点之前调用我的抽象吗?
这是 GraphGetConnection() 方法:
GraphClient clientConnection;
public GraphClient GraphGetConnection()
{
GraphOperationsLogger.Trace("Entering GetConnection Method");
clientConnection = new GraphClient(new Uri("http://localhost:7474/db/data"));
clientConnection.Connect();
return clientConnection;
}