0

我想将 sparql 查询结果列出到文本框(多行)或网格视图或列表中

但是下面显示的代码只返回一个结果!

请问有什么帮助吗?

IGraph g = new Graph();
g.LoadFromFile("example.owl");

try
{
    SparqlQueryParser par = new SparqlQueryParser();
    SparqlQuery q = par.ParseFromString(@"PREFIX uni:<http://www.semanticweb.org/salim/ontologies/2018/10/university-ontology-2#>SELECT ?P_Name (COUNT(?P_Name) AS ?Material_Num)
        WHERE
        {
        ?P uni:Have ?Material;
           uni:P_Name ?P_Name.
        }
        GROUP BY ?P_Name");

    object results = g.ExecuteQuery(q);

    if (results is SparqlResultSet)
    {
        SparqlResultSet rset = (SparqlResultSet)results;

        foreach (SparqlResult r in rset)
        {
            TextBox1.Text = r.ToString();
            //or
            GridView1.DataSource = r.ToString();
            GridView1.DataBind();
        }
    }
}
4

0 回答 0