2017-02-06 52 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"); 
}