本文整理汇总了C#中SparqlResultSet.AddResult方法的典型用法代码示例。如果您正苦于以下问题:C# SparqlResultSet.AddResult方法的具体用法?C# SparqlResultSet.AddResult怎么用?C# SparqlResultSet.AddResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparqlResultSet
的用法示例。
在下文中一共展示了SparqlResultSet.AddResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public void Apply(SparqlResultSet results)
{
switch (this._type)
{
case SparqlResultsType.Boolean:
results.SetResult(this._r);
break;
case SparqlResultsType.VariableBindings:
foreach (String var in this._vars)
{
results.AddVariable(var);
}
foreach (SparqlResult res in this._results)
{
results.AddResult(res);
}
break;
default:
throw new RdfParseException("The type property of a serialized SparqlResultSet did not contain a valid value");
}
}
示例2: Query
//.........这里部分代码省略.........
throw new RdfQueryException("Expected a single string value representing the serialization of the Graph resulting from a CONSTRUCT/DESCRIBE query but this was not received");
}
break;
case SparqlQueryType.Select:
case SparqlQueryType.SelectAll:
case SparqlQueryType.SelectAllDistinct:
case SparqlQueryType.SelectAllReduced:
case SparqlQueryType.SelectDistinct:
case SparqlQueryType.SelectReduced:
//Expect a DataTable containing columns for each Result Variable and a row for each solution
SparqlResultSet rset = new SparqlResultSet();
rset.SetResult(true);
//Get Result Variables
List<SparqlVariable> resultVars = query.Variables.Where(v => v.IsResultVariable).ToList();
foreach (SparqlVariable var in resultVars)
{
rset.AddVariable(var.Name);
}
Graph temp = new Graph();
//Convert each solution into a SPARQLResult
foreach (DataRow r in results.Rows)
{
SparqlResult result = new SparqlResult();
foreach (SparqlVariable var in resultVars)
{
if (r[var.Name] != null)
{
result.SetValue(var.Name, this.LoadNode(temp, r[var.Name]));
}
}
rset.AddResult(result);
}
finalResult = rset;
break;
default:
throw new RdfQueryException("Unable to process the Results of an Unknown query type");
}
this.Close(false);
}
catch
{
this.Close(true, true);
throw;
}
}
catch (RdfParseException)
{
//Unable to parse a SPARQL 1.0 query
//Have to attempt to detect the return type based on the DataTable that
//the SPASQL (Sparql+SQL) query gives back
//Make the Query against Virtuoso
VirtuosoCommand cmd = this._db.CreateCommand();
cmd.CommandText = "SPARQL " /*define output:format '_JAVA_' "*/ + sparqlQuery;
VirtuosoDataAdapter adapter = new VirtuosoDataAdapter(cmd);
adapter.Fill(results);
//Try to detect the return type based on the DataTable configuration
if (results.Rows.Count == 0 && results.Columns.Count > 0)
{