【问题标题】:How to implement where criteria with Neo4jClient F#?如何使用 Neo4jClient F# 实现 where 条件?
【发布时间】:2018-04-10 08:26:59
【问题描述】:

我尝试在 F# 中使用 Neo4jClient 查询特定节点的计数相关节点。但不断收到以下错误:

System.MissingMethodException:找不到方法:'System.Type Newtonsoft.Json.JsonContainerAttribute.get_NamingStrategyType()'。

我只是在包的文档中找不到答案。使用 lambda 函数进行过滤在“选择”阶段有效,但在“位置”无效。

[<CLIMutable>]
type User = { id : int; followers : int }

let tweetsCounted = 
  client.Cypher
    .Match("(u:User)-[:POSTED]->(t:Tweet)")
    .Where(fun u -> u.followers = 1000)
    .Return(fun (u : Cypher.ICypherResultItem) (t : Cypher.ICypherResultItem) -> u.As<User>(), t.Count())
    .Results
    .Select(fun (x, y) -> x.id, y)

【问题讨论】:

  • 我不确定问题出在哪里——你是说上面的代码出错了吗?如果是这样 - 是什么让它不会出错? where 阶段 - 您是指客户端上的 .Where 还是其他方式?
  • 我刚刚向客户端 (github.com/Readify/Neo4jClient/pull/270) 添加了一些 F# 测试,.Where 按预期工作,.Return 也是如此 - 也许你可以给我一个失败的测试,所以我可以看看更多吗?
  • 谢谢,首先传递一个类似的参数解决了这个问题,而 lambda 函数方式产生了上述错误。 `` .Where("u.followers = {followers}") .WithParams( {followers = filterUser.followers} ) `` 我重置了我的连接,重新启动了 FSI,但无法重现该问题。我可以确认上面的脚本按预期运行。

标签: json neo4j f# json.net neo4jclient


【解决方案1】:

这样这个问题就有答案了。

我添加了单元测试来测试 F# 关于 WHERERETURN 子句的功能,它们按预期通过(请参阅 http://github.com/Readify/Neo4jClient/pull/270)。

@AnotherNewbie 提到的错误在他们的环境中也无法重现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多