使用 DotNetRdf 和 Virtuoso Manager 保存数据
Persist Data with DotNetRdf and Virtuoso Manager
我试着按照 dotnetrdf
documentation to store data in a Virtuoso Server.
这是我的做法:
public void LoadGraph()
{
//Create our Storage Provider - this example uses Virtuoso Universal Server
VirtuosoManager virtuoso = new VirtuosoManager("creativeartefact.org", 1111, "DB", "user", "password");
//Load the Graph into an ordinary graph instance first
Graph g = new Graph();
virtuoso.LoadGraph(g, new Uri("http://creativeartefact.org/"));
//Then place the Graph into a wrapper
StoreGraphPersistenceWrapper wrapper = new StoreGraphPersistenceWrapper(virtuoso, g);
//Now make changes to this Graph as desired...
g.Assert(g.CreateUriNode(new Uri("http://creativeartefact.org/testB/123")), g.CreateUriNode("rdf:Type"), g.CreateUriNode(new Uri("http://creativeartefact.org/ontology/Artist")));
wrapper.Flush(); // mandatory, but doesn't help either
//Remember to call Dispose() to ensure changes get persisted when you are done
wrapper.Dispose();
}
但是 - 没有保存数据,也没有抛出异常。插入三元组后,三元组计数按预期增加了 1,但它并没有进入数据库。当我重新运行代码时,三次计数恢复到旧值。用户帐户具有 write
权限。
知道我错过了什么吗?
提前致谢,
弗兰克
您没有完整阅读正在关注的文档。
The easiest way to save a Graph to a Triple Store is to use the SaveGraph()
method of an IStorageProvider
implementation, see Triple Store Integration for more details.
我试着按照 dotnetrdf
documentation to store data in a Virtuoso Server.
这是我的做法:
public void LoadGraph()
{
//Create our Storage Provider - this example uses Virtuoso Universal Server
VirtuosoManager virtuoso = new VirtuosoManager("creativeartefact.org", 1111, "DB", "user", "password");
//Load the Graph into an ordinary graph instance first
Graph g = new Graph();
virtuoso.LoadGraph(g, new Uri("http://creativeartefact.org/"));
//Then place the Graph into a wrapper
StoreGraphPersistenceWrapper wrapper = new StoreGraphPersistenceWrapper(virtuoso, g);
//Now make changes to this Graph as desired...
g.Assert(g.CreateUriNode(new Uri("http://creativeartefact.org/testB/123")), g.CreateUriNode("rdf:Type"), g.CreateUriNode(new Uri("http://creativeartefact.org/ontology/Artist")));
wrapper.Flush(); // mandatory, but doesn't help either
//Remember to call Dispose() to ensure changes get persisted when you are done
wrapper.Dispose();
}
但是 - 没有保存数据,也没有抛出异常。插入三元组后,三元组计数按预期增加了 1,但它并没有进入数据库。当我重新运行代码时,三次计数恢复到旧值。用户帐户具有 write
权限。
知道我错过了什么吗?
提前致谢,
弗兰克
您没有完整阅读正在关注的文档。
The easiest way to save a Graph to a Triple Store is to use the
SaveGraph()
method of anIStorageProvider
implementation, see Triple Store Integration for more details.