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


C# SparqlResultSet.SetResult方法代码示例

本文整理汇总了C#中SparqlResultSet.SetResult方法的典型用法代码示例。如果您正苦于以下问题:C# SparqlResultSet.SetResult方法的具体用法?C# SparqlResultSet.SetResult怎么用?C# SparqlResultSet.SetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SparqlResultSet的用法示例。


在下文中一共展示了SparqlResultSet.SetResult方法的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");
     }
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:21,代码来源:ResultSetDeserializationInfo.cs

示例2: Query


//.........这里部分代码省略.........
                            //That string will be a Turtle serialization of the Graph

                            if (results.Rows.Count == 1 && results.Columns.Count == 1)
                            {
                                try
                                {
                                    //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);
                } 
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:67,代码来源:VirtuosoManager.cs


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