我想调用存储过程(请参阅上一个问题:Question with stored procedure for Neo4J as the answer但是,我无法通过流畅的查询界面看到这样做的方法。
有人可以帮忙吗?
我的Cypher查询:
MATCH(user:UserAccount)-[:HasPermission]->(permission:Permission)
WITH user, collect(permission) as permissions
CALL apoc.map.setKey( user, 'permissions', permissions ) YIELD value as UserAccount
RETURN UserAccount
我的Neo4jClient代码到目前为止:
_graphClient
.Cypher
.Match("(user:UserAccount)-[:HasPermission]->(permission:Permission)")
.With("user, collect(permission) as permissions")
// I need to call the stored procedure here.
.ReturnDistinct(
(userAccount) =>
new
{
UserAccount = userAccount.As<UserAccount>()
});
答案 0 :(得分:1)
我将保留下面的IRawGraphClient
版本,但对于版本1.1.0.39
(今天刚刚发布),您可以直接使用Call
和Yield
:
_graphClient.Cypher
.Match("(user:UserAccount)-[:HasPermission]->(permission:Permission)")
.With("user, collect(permission) as permissions")
.Call("apoc.map.setKey(user, 'permissions', permissions)").Yield("value AS UserAccount")
.ReturnDistinct(
(userAccount) => new { UserAccount = userAccount.As<UserAccount>() });
OLD VERSION(如果可以,请避免使用)
您是否按照我在您提出的GitHub错误中的建议尝试了IRawGraphClient
?
实质上,您可以将GraphClient
实例转换为IRawGraphClient
实例:
IRawGraphClient rgc = (IRawGraphClient) client;
然后用查询调用 - 它有点笨重,但是会是这样的:
var queryText = @"MATCH(user:UserAccount)-[:HasPermission]->(permission:Permission)
WITH user, collect(permission) as permissions
CALL apoc.map.setKey( user, 'permissions', permissions ) YIELD value as UserAccount
RETURN UserAccount"
var cypherQuery = new CypherQuery(queryText, null, CypherResultMode.Projection);
var results = rgc.ExecuteGetCypherResults<UserAccount>(cypherQuery);
我认为会起作用 - 我目前没有3.0设置进行测试,所以不能100%肯定,但请试试看。
我的目标是让.Call
/ .Yield<T>
方法对某个点进行排序