java neo4j实例讲解_Neo4j使用简单例子

Neo4j Versions

Most of the examples on this page are written with Neo4j 2.0 in mind, so they skip the START clause, and use clauses like MERGE. The focus of this page is about Cypher-to-C# syntax though, and should be equally useful in helping you translate a Neo4j 1.9 query to C#.

At the end of the day, you always need to start with a working Cypher query, then work out the equivalent C#.

Need more help?

If you have a working Cypher query, but can't translate it to C#, just post it on http://stackoverflow.com/questions/tagged/neo4jclient and we'll help you out pretty quickly.

Then, once we have the answer, we can add it to this page too so it helps other people.

User class

Most of the examples below assume you have the following class, to represent the structure of a user node:

public class User

{

public long Id { get; set; }

public string Name { get; set; }

public int Age { get; set; }

public string Email { get; set; }

}

Get all users by label

This Cypher:

MATCH (user:User)

RETURN user

Is this C#:

graphClient.Cypher

.Match("(user:User)")

.Return(user => user.As())

.Results

Get specific user

This Cypher:

MATCH (user:User)

WHERE user.Id = 1234

RETURN user

Is this C#:

graphClient.Cypher

.Match("(user:User)")

.Where((User user) => user.Id == 1234)

.Return(user => user.As())

.Results

Get a user, and the count of their friends

This Cypher:

OPTIONAL MATCH (user:User)-[FRIENDS_WITH]-(friend:User)

WHERE user.Id = 1234

RETURN user, count(friend) AS NumberOfFriends

Is this C#:

graphClient.Cypher

.OptionalMat

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值