如何在点网中与Gremlin连接? [英] How do I connect with Gremlin in dot Net?

查看:56
本文介绍了如何在点网中与Gremlin连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习格林姆林.我需要将gremlin连接到.net,下面是我的代码:

I am studying gremlin. I need to connect gremlin to .net and below is my code:

internal class Program
{
    private const string Host = "localhost";
    private const int Port = 8182;
    private const string NameTraversalSource = "gmodern";

    [Obsolete]
    private static void Main(string[] args)
    {
        Console.WriteLine("Start");

        Graph graph = new Graph();

        var client = new GremlinClient(new GremlinServer(Host, Port));

        var g = graph.Traversal().WithRemote(new DriverRemoteConnection(client));

        g.AddV("person").Property("name", "marko");

        var re = g.V().HasLabel("person").Values<string>("name").ToList();
        foreach (var c in re)
        {
            Console.WriteLine(c);
        }

        Console.WriteLine("End");
        Console.ReadKey();
    }
}

我不知道为什么它不能回答期望的结果.我添加了值为"marko"的顶点和名称属性.我需要将其打印出来.但它不会打印.为什么?救救我.

I don't know why it doesn't answer the desired result. I added vertex and name property with value of "marko". I need to print it out. But it doesn't print. Why? Help me.

推荐答案

我投票决定将其关闭,因为我认为需要更多详细信息,但我认为我意识到了这个问题.在许多方面,随着更多的重复"问题的出现,这个问题可以被解决.许多面向Gremlin的问题往往都具有以下答案:您需要迭代遍历.

I voted to close this as I thought more details were required, but I think I realize the problem. In many ways the question could be closed as more of a "duplicate" as many Gremlin oriented questions tend to have this answer: You need to iterate your traversal.

以下行不执行任何操作:

The following line does nothing:

g.AddV("person").Property("name", "marko");

它所做的只是创建一个遍历(即 Iterator ).它不执行.要执行,您必须使用某种形式的终端步骤对其进行迭代.由于您对结果不做任何事情,您可能应该使用 iterate(),例如:

All it does is create a traversal (i.e. an Iterator). It does not execute it. To execute you must iterate it with some form of terminal step. Since you are aren't doing anything with the result you should probably use iterate() like:

g.AddV("person").Property("name", "marko").iterate();

这篇关于如何在点网中与Gremlin连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆