通过 C#.net 连接到 OrientDB
Connect to OrientDB via C#.net
我正在使用 Orient-db 2.2.13 和 VisualStudio2015,我正在尝试从 c#.net 到现有的 orientDB 执行一个简单的 "test connection" 方法。
在java中执行起来非常简单:
OrientGraphFactory factory = new OrientGraphFactory(remoteUrl, user, password, false);
result = factory.getNoTx().command(new OCommandSQL("select....")).execute();
但在 C#.Net 中似乎不太容易。
到目前为止我得到的只是这个(而且它不起作用)
OServer _server = new OServer(_hostname, _port, _rootUserName, _rootUserPassword);
ODatabase odb = new ODatabase(_hostname, _port, _DBname, ODatabaseType.Graph, _rootUserName, _rootUserPassword);
你能帮帮我吗?
今天刚试过使用 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);
尝试使用此模板开始,然后使用
执行命令
database.execute(..);
这对我有用(VS2015、Orient 2.2.5、OrientDB-Net.binary.Innov8tive 0.1.12)
using (ODatabase db = new ODatabase(server, port, dbname, ODatabaseType.Graph, user, pw))
{
string rid="#12:0";
OVertex v1 = db.Query<OVertex>($"select * from {rid}")[0];
var myfield = v1.GetField<string>("string_field_name");
}
我正在使用 Orient-db 2.2.13 和 VisualStudio2015,我正在尝试从 c#.net 到现有的 orientDB 执行一个简单的 "test connection" 方法。
在java中执行起来非常简单:
OrientGraphFactory factory = new OrientGraphFactory(remoteUrl, user, password, false);
result = factory.getNoTx().command(new OCommandSQL("select....")).execute();
但在 C#.Net 中似乎不太容易。 到目前为止我得到的只是这个(而且它不起作用)
OServer _server = new OServer(_hostname, _port, _rootUserName, _rootUserPassword);
ODatabase odb = new ODatabase(_hostname, _port, _DBname, ODatabaseType.Graph, _rootUserName, _rootUserPassword);
你能帮帮我吗?
今天刚试过使用 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);
尝试使用此模板开始,然后使用
执行命令database.execute(..);
这对我有用(VS2015、Orient 2.2.5、OrientDB-Net.binary.Innov8tive 0.1.12)
using (ODatabase db = new ODatabase(server, port, dbname, ODatabaseType.Graph, user, pw))
{
string rid="#12:0";
OVertex v1 = db.Query<OVertex>($"select * from {rid}")[0];
var myfield = v1.GetField<string>("string_field_name");
}