本文整理汇总了C#中SparqlResultSet.AddVariable方法的典型用法代码示例。如果您正苦于以下问题:C# SparqlResultSet.AddVariable方法的具体用法?C# SparqlResultSet.AddVariable怎么用?C# SparqlResultSet.AddVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparqlResultSet
的用法示例。
在下文中一共展示了SparqlResultSet.AddVariable方法的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
//.........这里部分代码省略.........
//Use StringParser to parse
String data = results.Rows[0][0].ToString();
TurtleParser ttlparser = new TurtleParser();
Graph g = new Graph();
StringParser.Parse(g, data, ttlparser);
finalResult = g;
}
catch (RdfParseException parseEx)
{
throw new RdfQueryException("Expected a valid Turtle serialization of the Graph resulting from a CONSTRUCT/DESCRIBE query but the result failed to parse", parseEx);
}
}
else
{
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;
}
}