将sparql结果列出到asp.net组件中

时间:2019-06-06 17:22:37

标签: asp.net sparql semweb

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

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

请帮忙吗?

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();
        }
    }
}

0 个答案:

没有答案