var statementText var statementParameters = 这两句不是一般的调用diver里面的run方法,这个是什么操作可以传参进去吗,就是指定查询那部电影
namespace Neo4jDotNetDemo.Controllers { using System.Collections.Generic; using System.Web.Http; using Neo4j.Driver.V1;
[RoutePrefix("graph")]
public class GraphController : ApiController
{
[HttpGet]
[Route("{limit:int?}", Name = "getgraph")]
//public GraphController(string uri, string user, string password)
//{
// WebApiConfig.Neo4jDriver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
//} //bolt协议的url 用户名密码字符串 2.指定的url以及授权模式
public IHttpActionResult Index(int limit = 10, string q = "Matrix")
{
//query = ("MATCH (m:Movie)<-[:ACTED_IN]-(a:Person) "
// "RETURN m.title as movie, collect(a.name) as cast "
// "LIMIT {limit}")
var statementText = "MATCH (a:Person)-[:ACTED_IN]->(m:Movie) RETURN m.title as movie, collect(a.name) as cast LIMIT {limit}";
var statementParameters = new Dictionary<string, object> {{"limit", limit}};
var nodes = new List<NodeResult>();
var relationships = new List<object>();
using (var session = WebApiConfig.Neo4jDriver.Session(AccessMode.Read))
{
var result = session.Run(statementText, statementParameters);
var i = 0;
foreach (var record in result)
{
var target = i;
nodes.Add(new NodeResult { title = record["movie"].As<string>(), label = "movie" });
i += 1;
var castMembers = record["cast"].As<List<string>>();
foreach (var castMember in castMembers)
{
var source = nodes.FindIndex(c => c.title == castMember);
if (source == -1)
{
nodes.Add(new NodeResult { title = castMember, label = "actor" });
source = i;
i += 1;
}
relationships.Add(new { source, target });
}
}
}
return Ok(new {nodes, links = relationships});
}
}
public class NodeResult
{
public string title { get; set; }
public string label { get; set; }
}
public class Movie
{
public string title { get; set; }
public int released { get; set; }
public string tagline { get; set; }
}
public class Person
{
public string name { get; set; }
public int born { get; set; }
}
}
想请问一下 var statementText = “MATCH (a:Person)-[:ACTED_IN]->(m:Movie) RETURN m.title as movie, collect(a.name) as cast LIMIT {limit}”; var statementParameters = new Dictionary<string, object> {{“limit”, limit}}; 这两句不是一般的调用diver里面的run方法,这个是什么操作可以传参进去吗,就是指定查询那部电影