Q:

how to return value in self defined type in neo4jclient

I'm new to neo4jclient and i don't know how to return self defined type in neo4jclient. 
i have the following cypher:
var result = client. Cypher
                .Match("(u:User)-[:" + FriendRelation + "]->(friend:User)")
                .Return((user, friend) => new RelationInDB(user. As<User>().id, friend. As<User>().id)).Results;

i want to return all id pair that have friend relation and i want to store two id in self defined class--RelationInDB, but i don't know how to write Return(i know the return above is wrong)
Can anyone help? 

A:

OK, there are 2 things you'll find which are causing you issues:

You can't return into the constructor of a class, you need to use a default constructor and property setting
Your return statement has (user, friend) => but your match statement has (u:User).  Your return statement should be: (u, friend) =>

To that end:
 var results = client
      .Cypher
      .Match("(u:User)-[:" + FriendRelation + "]->(friend:User)")
      .Return((u, friend) => new RelationInDB{UserId = u.As<User>().Id, FriendId = friend. As<User>().Id}).Results;

My RelationInDB class is defined as:
public class RelationInDB
{
    public int FriendId { get;  set; }
    public int UserId { get;  set; }

    public RelationInDB() { }
}

If you can't change your RelationInDB class and you need to use it as is, you will have to use an anonymous type for your return:
 var results = client
      .Cypher
      .Match("(u:User)-[:" + FriendRelation + "]->(friend:User)")
      .Return((u, friend) => new {UserId = u.As<User>().Id, FriendId = friend. As<User>().Id}).Results;

and parse afterwards with something like:
var relsInDb = results. Select(result => new RelationInDB(result. UserId, result. FriendId));

