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