2017-02-06 48 views
1

我正在使用Orient-db 2.2.13和VisualStudio2015,我试图从c#.net到现有的orientDB执行一个简单的“测试连接”方法。通过C#连接到OrientDB .net

在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); 

你能帮助我吗?

回答

0

使用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(..); 
0

这对我的作品(VS2015尝试使用这个模板staarting然后执行命令今天刚试过,东方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"); 
}