1
votes

I'm very new to Neo4J and this client, starting to get the hang of things but having a strange problem. I have an entity like the below

public class MemberAccount : Entity<MemberAccount>, IValidatable
{
  public string StudioName { get; set; }
  public string EmailAddress { get; set; }
  public string OwnerFirstName { get; set; }
  public string OwnerLastName { get; set; }
  public MemberAccountType AccountType { get; set; }
  public string Password { get; set; }
  public string PostCode { get; set; }

  [JsonProperty("PrimaryPhone")]
     public PhoneNumber PrimaryPhone { get; set; }
}

Basically it seems as though the PhoneNumber value object is causing a create statement to fail with the below error

System.ArgumentNullException : Value cannot be null. Parameter name: uriString at System.Uri..ctor(String uriString) at Neo4jClient.GraphClient.GetLastPathSegment(String uri) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs: line 686 at Neo4jClient.GraphClient.Create(TNode node, IEnumerable1 relationships, IEnumerable1 indexEntries) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs: line 334 at StudioBooker.Persistence.Repository.Studio.Neo4JRepositories.Neo4JMemberAccountRepository.Save(MemberAccount memberAccount) in Neo4JMemberAccountRepository.cs: line 29 at StudioBooker.Persistence.Tests.Neo4JRepositoryTests.Neo4JMemberAccountRepositoryTests.SaveTest() in Neo4JMemberAccountRepositoryTests.cs: line 31

The JSON thats generated by newtonsoft looks like

{
    "StudioName": "Studio",
    "EmailAddress": "[email protected]",
    "OwnerFirstName": "Test",
    "OwnerLastName": "Test",
    "AccountType": 1,
    "Password": "Password",
    "PostCode": "W3 6AE",
    "PrimaryPhone": {
        "AreaCode": "01491",
        "Number": "651321"
    },
    "Id": "00000000-0000-0000-0000-000000000000"
}

I'm strugging to understand why the stack trace above occurs as I would've thought it's just a simple property as far as the client would be concerned although there must be more to it. Any help would be appreciated :)

Thanks

1

1 Answers

2
votes

The error message is a bit useless; I should work on that.

Generally though, you can't use nested types like that. Neo4j only stores key-values, where the values are primitives. You need to either flatten your phone number to properties on the parent, or store it in a different node.