当前位置: 首页>>代码示例>>C#>>正文


C# SparqlResultSet.Select方法代码示例

本文整理汇总了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));
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:5,代码来源:HtmlSchemaWriter.cs

示例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));
     }
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:52,代码来源:SparqlResultDataObjectHelper.cs


注:本文中的SparqlResultSet.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。