Persist Data with DotNetRdf and Virtuoso Manager

▼魔方 西西 提交于 2019-12-12 05:15:00

问题


I tried following the dotnetrdf documentation to store data in a Virtuoso Server.

Here is what I do:

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();
}

But - no data is saved and no exception is thrown. After inserting the triple, the triple count is raised by 1 as expected, but it doesn't make it's way into the database. The triple count is back to the old value when I rerun the code. The user account has write permissions.

Any idea what I am missing?

Thanks in advance,
Frank


回答1:


You're not fully reading the doc you're following.

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.



来源:https://stackoverflow.com/questions/39980735/persist-data-with-dotnetrdf-and-virtuoso-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!