0

所以我有一个查询,并试图在调试输出中显示它,当我运行文件时,它给了我一个以 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,所以这可能是一个非常基本的问题。非常感谢:)

4

1 回答 1

1

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

既然这似乎是一个控制台应用程序,为什么不直接使用Console.WriteLine()呢?

于 2016-12-12T10:02:28.173 回答