Search code examples
c#.netvisual-studio-2015orientdbgraph-databases

Connect to OrientDB via C#.net


I am using Orient-db 2.2.13 and a VisualStudio2015 and I am trying to perform a simple "test connection" method from c#.net to an existing orientDB I have.

In java it is very simple to perform:

OrientGraphFactory factory = new OrientGraphFactory(remoteUrl, user, password, false);
result = factory.getNoTx().command(new OCommandSQL("select....")).execute();

But in C#.Net it seems to be a less easy. All I got so far is this (and it is NOT working)

OServer _server = new OServer(_hostname, _port, _rootUserName, _rootUserPassword);
ODatabase odb = new ODatabase(_hostname, _port, _DBname, ODatabaseType.Graph, _rootUserName, _rootUserPassword);

can you help me please?


Solution

  • Just tried today using OrientDB 2.2.16

    ConnectionOptions opts = new ConnectionOptions();
    
    opts.HostName = "localhost";
    opts.UserName = "root";
    opts.Password = "mypassword";
    opts.Port = 2424;
    opts.DatabaseName = "mydatabasename";
    opts.DatabaseType = ODatabaseType.Graph;
    
    database = new ODatabase(opts);
    
    Console.Write(database.Size);
    

    Try staarting using this template and then execute command using

    database.execute(..);