2017-02-21 181 views
1

我有一臺AllegroGraph服務器正在運行,並且在查詢遠程數據存儲時遇到問題,關於文檔的信息很少。使用dotNetRDF查詢AllegroGraph

這裏是我的律一段代碼:

using System; 
using VDS.RDF; 
using VDS.RDF.Storage; 

namespace PoC { 
    class Program { 
    static void Main(string[] args) { 
     string server = "http://server"; 
     string repo = "repo"; 
     string username = "username"; 
     string password = "password"; 

     AllegroGraphConnector agraph = new AllegroGraphConnector(server, repo, username, password); 

     Options.HttpDebugging = true; 
     Options.HttpFullDebugging = true; 

     agraph.Query("SELECT * WHERE { emid:_PCAT_0001 ?p ?o }"); 
     Console.ReadLine(); 
    } 
    } 
} 

MALFORMED QUERY: Parse error: namespace mapping for "emid" not defined when expanding QName "emid:_PCAT_0001".

雖然AllegroGraph的WebView我可以運行完全相同的查詢和命名空間被加載到庫中。

我該如何解決?

回答

1

您需要在查詢中聲明前綴emid:。據推測,AllegroGraph WebView UI會自動爲你做這件事,但普通的SPARQL端點不會。

嘗試使用這樣的事情:

agraph.Query("PREFIX emid: <http://your.uri.goes/here> SELECT * WHERE { emid:_PCAT_0001 ?p ?o }"); 

顯然就應該更換,假冒URI與真正的URI,你的EMID:前綴映射到!