本文整理汇总了C#中SparqlResultSet.Select方法的典型用法代码示例。如果您正苦于以下问题:C# SparqlResultSet.Select方法的具体用法?C# SparqlResultSet.Select怎么用?C# SparqlResultSet.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparqlResultSet
的用法示例。
在下文中一共展示了SparqlResultSet.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCaptionedInformation
private void GenerateCaptionedInformation(HtmlWriterContext context, String caption, SparqlResultSet results, String var)
{
if (results == null) return;
this.GenerateCaptionedInformation(context, caption, results.Select(r => r[var]).Where(n => n != null));
}
示例2: BindDataObjects
public IEnumerable<IDataObject> BindDataObjects(SparqlResultSet sparqlResultSet, bool resultsAreOrdered = false)
{
if (sparqlResultSet == null) throw new ArgumentNullException(nameof(sparqlResultSet));
var resourceTriples = new Dictionary<string, List<Triple>>();
string lastLoadedSubject = null;
switch (sparqlResultSet.Variables.Count())
{
case 1:
// Single column results set contains only data object IRIs
foreach (var uriNode in sparqlResultSet.Select(row => row[0] as IUriNode).Where(uriNode => uriNode?.Uri != null))
{
yield return _storeContext.MakeDataObject(uriNode.Uri.ToString());
}
break;
case 3:
// Columns are triples, s, p, o in that order
foreach (var t in sparqlResultSet.Select(row=>MakeTriple(row[0], row[1], row[2])))
{
if (resourceTriples.ContainsKey(t.Subject))
{
resourceTriples[t.Subject].Add(t);
}
else
{
resourceTriples[t.Subject] = new List<Triple> {t};
}
if (resultsAreOrdered && lastLoadedSubject != null && !lastLoadedSubject.Equals(t.Subject))
{
// Have collected all the triples we are going to see for the previously encountered subject, so emit its data object now
yield return MakeDataObject(lastLoadedSubject, resourceTriples[lastLoadedSubject]);
}
lastLoadedSubject = t.Subject;
}
if (resultsAreOrdered && lastLoadedSubject != null)
{
// Emit the final result
yield return MakeDataObject(lastLoadedSubject, resourceTriples[lastLoadedSubject]);
}
else
{
// We have batched up all of the triples and can now emit the separate data objects
foreach (var entry in resourceTriples)
{
yield return MakeDataObject(entry.Key, entry.Value);
}
}
break;
default:
throw new ArgumentException(
$"Expected a result set with either 1 or 3 columns. Got a result set with {sparqlResultSet.Variables.Count()} columns", nameof(sparqlResultSet));
}
}