如何在输出中显示查询

时间:2016-12-10 17:55:55

标签: c# visual-studio sparql rdf dotnetrdf

所以我有一个查询,我试图在调试输出中显示它,当我运行该文件时,它给我一个以iisexpress.exe开头的输出列表:https://gyazo.com/fd9eb832dfcc08571b31490103b85b49 但没有实际结果?我正在尝试使用dotnetRDF首次在Visual Studios2015上运行查询。我的代码如下:

public static void Main(String[] args)
        {
            Debug.WriteLine("SQLAQL query example");
            //Define a remote endpoint
            //Use the DBPedia SPARQL endpoint with the default Graph set to DBPedia
            SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");

            //SPARQL query to show countries, population, capital for countries where population is more than 100000 and limit results to 50
            String queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>  " +
              "PREFIX type: <http://dbpedia.org/class/yago/> " +
              "PREFIX prop: <http://dbpedia.org/property/>  " +
              "SELECT ?country_name ?population ?cptl  " +
              "WHERE {  " +
              "?country rdf:type type:Country108544813.  " +
              "?country rdfs:label ?country_name.  " +
              "?country prop:populationEstimate ?population.  " +
              "?country dbo:capital ?cptl  " +
              "FILTER (?population > 1000000000) .  " +
              "}" +
              "LIMIT 50 ";
            Debug.WriteLine("queryString: [" + queryString + "]");

            //Make a SELECT query against the Endpoint
            SparqlResultSet results = endpoint.QueryWithResultSet(queryString);
            foreach (SparqlResult result in results)
            {
                Debug.WriteLine(result.ToString());
            }

        }

刚学习SPARQL所以这可能是一个非常基本的问题。 非常感谢:)

1 个答案:

答案 0 :(得分:1)

您需要确保编译代码并在调试模式下运行。如果不是,则Debug.WriteLine()将无效。您提供的输出不完整,未来参考最好复制并粘贴到您的问题而不是发布屏幕截图。

由于这似乎是一个控制台应用程序,为什么不只使用Console.WriteLine()呢?