当前位置:   article > 正文

C# 连接neo4j数据库,包括非默认的neo4j默认库_neo4j与c#

neo4j与c#

 官方文档没找见,自己在源码里面找到的

  1. private string _dbHost = "bolt://localhost:7687";
  2. private string _dbUser = "neo4j";
  3. private string _dbPassword = "******";
  4. private IDriver? _driver;
  5. public CQLOperation(string _database = "neo4j")
  6. {
  7. this.database = _database;
  8. }
  9. public string database { get; set; }
  10. public string ExcuteQuery(string Cql)
  11. {
  12. _driver = GraphDatabase.Driver(_dbHost, AuthTokens.Basic(_dbUser, _dbPassword));
  13. using (var session = _driver.Session(o => o.WithDatabase(database)))
  14. {
  15. var res = session.ExecuteRead(work =>
  16. {
  17. return work.Run(Cql).ToList();
  18. });
  19. string res_str = JsonConvert.SerializeObject(res);
  20. return res_str;
  21. }
  22. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/691910
推荐阅读
相关标签
  

闽ICP备14008679号