Я создал метод, который принимает в свойствах узла и обновляет эти proerties на указанном узле, но когда он получает в код, чтобы сделать обновление я получаю System.NullReferenceException: Object reference not set to an instance of an object.
Null Reference Исключение при обновлении узла Neo4jClient .NET
Введите код:
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;
, потому что Im уже передал его в качестве параметра для метода? И должен ли я называть мой абстрагированный 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;
}
I см. больше вещей, которые могут вызвать исключение, какой из них? 'nodeRef',' graphOp' или 'clientConnection' – Silvermind
Его' clientConnection.Update() ', который выдает ошибку @Silvermind –
Таким образом, это означает, что' clientConnection' имеет значение null. Где вы его создаете? – Silvermind