0

我收到以下代码错误:

在此处输入图像描述

这是代码,我需要这个方法来返回最大值吗?它是 IEnumerable 还是 int?

public IEnumerable<int> GraphGetMaxVersion(IEnumerable<Node<VersionNode>> nodeId)
        {
            IEnumerable<int> nodes = null;

            clientConnection = graphOperations.GraphGetConnection();

                var query = clientConnection
                    .Cypher
                    .Start(new
                    {
                        n = nodeId
                    })
                    .Return((maxVersion) => new
                    {
                        MaxVersion = Return.As<int>("max.Version")
                    });
                nodes = query.Results;

            return nodes;
        }

这是我要执行的查询:

START n=node(2,3,4)
RETURN max(n.property)
4

3 回答 3

1

你要这个:

public int GraphGetMaxVersion(IEnumerable<NodeReference<VersionNode>> nodes)
{
    return graphClient.Cypher
        .Start(new { n = nodes })
        .Return(() => Return.As<int>("max(n.Version)"))
        .Results
        .Single();
}
  1. 我没有测试过。我只是在文本框中把它搞砸了,但它应该可以工作。
  2. 如果您不需要返回复杂类型,请不要。也就是Return(() => new { Foo = All.Count() })变成Return(() => All.Count())
  3. 如果您不需要在返回 lambda 中使用标识,请不要将其传入。也就是说,这个参数是没有意义的:Return((somePointlessIdentityHere) => All.Count())
  4. 使用 Neo4jClient 1.0.0.570 或更高版本,或更改.Start(new { n = nodes }).Start(new { n = nodes.ToArray() }).
于 2013-05-09T03:30:07.723 回答
0

阅读这篇文章后,当我对方法进行这些更改时,不会引发任何错误。

    public int GraphGetMaxVersion(int nodeId)
    {
        int nodes = 0;

        clientConnection = graphOperations.GraphGetConnection();

            var query = clientConnection
                .Cypher
                .Start(new
                {
                    n = nodeId
                })
                .Return((maxVersion) => new
                {
                    MaxVersion = Return.As<int>("max(n.Version)")
                })
                .Results
                .Single();
            nodes = query.MaxVersion;

        return nodes;
    }
于 2013-05-08T10:04:54.460 回答
0

你应该这样做:

// Return Max follwoer node ID:
    public float ReturnMaxFollowerID(IGraphClient Client)
    {
        return Client.Cypher
          .Match("(n:User)")
          .Return(() => Return.As<float>("max(n.userID)"))
          .Results
          .Single();

    }
于 2015-05-20T15:47:41.117 回答