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


(Muhamed G) #1

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:

                .Where<Post>(q => q.Uid == questionId)
                .Return((u, r, q) => new
                    questionPost = q.As<Post>(),
                    involvedUsers = u.CollectAsDistinct<UserModel>(),
                    relations = r.CollectAs<string>()

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?

(Andrew Bowman) #2

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