I have a Neo4j database which, for the sake of simplicity, contains User nodes and University nodes - where a User can be related to a University via the [:STUDENT_AT] relationship.
I want to return both the User details and the University details for a specific user, in this case querying by the 'username' value.
The query itself works fine, however I'm unable to work out the correct method for getting the deserialiser in Neo4jClient to give me the two objects to work with. Below is what I believe should work, but - alas - it does not.
graph.Cypher
.Start("user", "node(*)")
.Match("user-[:STUDENT_AT]->university")
.Where<User>(user =>
user.Username != null &&
user.Username.ToLower() == username.ToLower())
.Return((user, university) => new
{
User = user.As<User>(),
University = university.As<University>()
})
.Results;
Where graph
is an IGraphClient
which has successfully connected to Neo4j.
The error I recieve is...
The query response contains columns User, University however <>f__AnonymousType0`2[[XYZ.Entities.User, XYZ.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[XYZ.Entities.University, XYZ.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] does not contain publically settable properties to receive this data.
So in summary, if anyone could provide me with a method of getting objects from a cypher query which returns multiple columns using Neo4jClient I would be extremely thankful!