本文整理汇总了C#中TripleStore.ExecuteUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# TripleStore.ExecuteUpdate方法的具体用法?C# TripleStore.ExecuteUpdate怎么用?C# TripleStore.ExecuteUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TripleStore
的用法示例。
在下文中一共展示了TripleStore.ExecuteUpdate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SparqlUpdateInsertDataWithSkolemBNodes
public void SparqlUpdateInsertDataWithSkolemBNodes()
{
TripleStore store = new TripleStore();
Graph g = new Graph();
store.Add(g);
String prefixes = "PREFIX rdf: <" + NamespaceMapper.RDF + ">\n PREFIX xsd: <" + NamespaceMapper.XMLSCHEMA + ">\n PREFIX ex: <http://example.org/>\n PREFIX rdl: <http://example.org/roles>\n PREFIX tpl: <http://example.org/template/>\n";
String insert = prefixes + "INSERT DATA { " + InsertPatterns1 + "}";
Console.WriteLine(insert.Replace("_:template","<_:template>"));
Console.WriteLine();
store.ExecuteUpdate(insert.Replace("_:template", "<_:template>"));
insert = prefixes + "INSERT DATA {" + InsertPatterns2 + "}";
Console.WriteLine(insert);
Console.WriteLine();
store.ExecuteUpdate(insert);
foreach (Triple t in g.Triples)
{
Console.WriteLine(t.ToString());
}
}
示例2: Apply
/// <summary>
/// Applies reasoning on the Input Graph materialising the generated Triples in the Output Graph
/// </summary>
/// <param name="input">Input Graph</param>
/// <param name="output">Output Graph</param>
public void Apply(IGraph input, IGraph output)
{
TripleStore store = new TripleStore();
store.Add(input);
if (!ReferenceEquals(input, output))
{
store.Add(output, true);
}
//Apply each rule in turn
foreach (String[] rule in this._rules)
{
//Build the final version of the rule text for the given input and output
StringBuilder ruleText = new StringBuilder();
//If there's a Base URI on the Output Graph need a WITH clause
if (output.BaseUri != null)
{
ruleText.AppendLine("WITH <" + this._formatter.FormatUri(output.BaseUri) + ">");
}
ruleText.AppendLine(rule[0]);
//If there's a Base URI on the Input Graph need a USING clause
if (input.BaseUri != null)
{
ruleText.AppendLine("USING <" + this._formatter.FormatUri(input.BaseUri) + ">");
}
ruleText.AppendLine(rule[1]);
ISyntaxValidationResults results = this._validator.Validate(ruleText.ToString());
if (results.IsValid)
{
store.ExecuteUpdate((SparqlUpdateCommandSet)results.Result);
}
}
}
示例3: SparqlUpdateLoad
public void SparqlUpdateLoad()
{
TripleStore store = new TripleStore();
LoadCommand loadLondon = new LoadCommand(new Uri("http://dbpedia.org/resource/London"));
LoadCommand loadSouthampton = new LoadCommand(new Uri("http://dbpedia.org/resource/Southampton"), new Uri("http://example.org"));
store.ExecuteUpdate(loadLondon);
store.ExecuteUpdate(loadSouthampton);
Assert.AreEqual(2, store.Graphs.Count, "Should now be 2 Graphs in the Store");
Assert.AreNotEqual(0, store.Triples.Count(), "Should be some Triples in the Store");
foreach (IGraph g in store.Graphs)
{
foreach (Triple t in g.Triples)
{
Console.Write(t.ToString());
if (g.BaseUri != null)
{
Console.WriteLine(" from " + g.BaseUri.ToString());
}
else
{
Console.WriteLine();
}
}
}
}
示例4: SparqlUpdateCreateDrop
public void SparqlUpdateCreateDrop()
{
TripleStore store = new TripleStore();
Console.WriteLine("Store has " + store.Graphs.Count + " Graphs");
//Create a couple of Graphs using Create Commands
CreateCommand create1 = new CreateCommand(new Uri("http://example.org/1"));
CreateCommand create2 = new CreateCommand(new Uri("http://example.org/2"));
store.ExecuteUpdate(create1);
store.ExecuteUpdate(create2);
Assert.AreEqual(3, store.Graphs.Count, "Store should have now had three Graphs");
Assert.AreEqual(0, store.Triples.Count(), "Store should have no triples at this point");
//Trying the same Create again should cause an error
try
{
store.ExecuteUpdate(create1);
Assert.Fail("Executing a CREATE command twice without the SILENT modifier should error");
}
catch (SparqlUpdateException)
{
Console.WriteLine("Executing a CREATE command twice without the SILENT modifier errored as expected");
}
//Equivalent Create with SILENT should not error
CreateCommand create3 = new CreateCommand(new Uri("http://example.org/1"), true);
try
{
store.ExecuteUpdate(create3);
Console.WriteLine("Executing a CREATE for an existing Graph with the SILENT modifier suppressed the error as expected");
}
catch (SparqlUpdateException)
{
Assert.Fail("Executing a CREATE for an existing Graph with the SILENT modifier should not error");
}
DropCommand drop1 = new DropCommand(new Uri("http://example.org/1"));
store.ExecuteUpdate(drop1);
Assert.AreEqual(2, store.Graphs.Count, "Store should have only 2 Graphs after we executed the DROP command");
try
{
store.ExecuteUpdate(drop1);
Assert.Fail("Trying to DROP a non-existent Graph should error");
}
catch (SparqlUpdateException)
{
Console.WriteLine("Trying to DROP a non-existent Graph produced an error as expected");
}
DropCommand drop2 = new DropCommand(new Uri("http://example.org/1"), ClearMode.Graph, true);
try
{
store.ExecuteUpdate(drop2);
Console.WriteLine("Trying to DROP a non-existent Graph with the SILENT modifier suppressed the error as expected");
}
catch (SparqlUpdateException)
{
Assert.Fail("Trying to DROP a non-existent Graph with the SILENT modifier should suppress the error");
}
}
示例5: SparqlUpdateModify
public void SparqlUpdateModify()
{
TripleStore store = new TripleStore();
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = null;
store.Add(g);
IUriNode rdfType = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType));
Assert.AreNotEqual(0, store.GetTriplesWithPredicate(rdfType).Count(), "Store should contain some rdf:type Triples");
String update = "DELETE {?s a ?type} WHERE {?s a ?type}";
SparqlUpdateParser parser = new SparqlUpdateParser();
SparqlUpdateCommandSet cmds = parser.ParseFromString(update);
store.ExecuteUpdate(cmds);
Assert.AreEqual(0, store.GetTriplesWithPredicate(rdfType).Count(), "Store should contain no rdf:type Triples after DELETE command executes");
}