cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to cast to proper type after retrieving all relationships in the .NET neo4jclient?

So I have a neo4j database to store a forum-like data structure.. posts, replies, reactions.. etc.

I'm trying to get a single Post details with all replies, reactions and related users.. so I'm doing this:


_graphClient.Cypher
                .Match("(u:User)-[r]->(q:Question)")
                .Where<Post>(q => q.Uid == questionId)
                .Return((u, r, q) => new
                {
                    questionPost = q.As<Post>(),
                    involvedUsers = u.CollectAsDistinct<UserModel>(),
                    relations = r.CollectAs<string>()
                }).ResultsAsync;

I have a problem in this line relations = r.CollectAs<string>() .. I have already a Reply class and a PostReaction class.. but how to get them dynamically?

Is the model I'm using is wrong? Should I specify the relationship type and do multiple queries?

1 REPLY 1

Can you return type(r) instead of r? If you only need the type of the relationship that should work.