【问题标题】:Persist Data with DotNetRdf and Virtuoso Manager使用 DotNetRdf 和 Virtuoso Manager 持久化数据
【发布时间】:2016-10-11 15:17:32
【问题描述】:

我尝试按照dotnetrdf documentation 将数据存储在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 权限。

知道我错过了什么吗?

提前致谢,
弗兰克

【问题讨论】:

    标签: virtuoso dotnetrdf


    【解决方案1】:

    您没有完全阅读您关注的文档。

    将 Graph 保存到 Triple Store 的最简单方法是使用 IStorageProvider 实现的 SaveGraph() 方法,有关详细信息,请参阅 Triple Store Integration

    【讨论】:

    • 好吧,据我了解,这是一种存储更改的替代方式,示例明确指出“调用 Dispose() 以确保更改持久化”-我理解为“更改将存储在三重存储中”。 “StoreGraphPersistanceWrapper”还有什么用途?但无论如何 - 使用 virtuoso.SaveGraph(g) 命令将更改存储在 Triple Store 中,而不使用 StoreGraphPersistanceWrapper - 所以感谢您的解决方案!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 2020-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多