Search code examples
c#virtuosodotnetrdf

Updating a Virtuoso graph with dotnetrdf


After struggling with dotnetrdf and Virtuoso to save my graph, I try to update the graph with my changes. Again, I followed the documentation in section UpdateGraph(), and created the following code:

// and store the graph
if (_virtuoso.UpdateSupported)
    _virtuoso.UpdateGraph(insertGraph.BaseUri, insertGraph.Triples, null);
else
    log.Add("Updating not supported. Changes not stored");

The insertGraph is the Graph that contains my additions. I checked that BaseUri has the correct value and insertGraph.Triples contains my new Triples. _virtuoso is an instance of VirtuosoManager, with which I am able to LoadGraph and SaveGraph.

The code doesn't raise any exception, but still - no triple is inserted in the Virtuoso store. Any idea, what might be the problem or how I might get more information about the problem?

Thanks in advance,
Frank


Solution

  • The trick was to call the Dispose method on the Virtuoso Manager. Only this forces the updates to be stored.

    VirtuosoManager virtuosoManager = new VirtuosoManager(Configuration.VirtuosoServerName, Configuration.VirtuosoServerPort, VirtuosoManager.DefaultDB, User, Password);
    virtuosoManager.UpdateGraph(graphUri, TriplesToAdd, TriplesToRemove);
    
    // NECESSARY!! Otherwise, the changes won't be commited!      
    virtuosoManager.Dispose();