Library for .NET that returns SPARQL results in some structured List instead of standard XML format?

StackOverflow https://stackoverflow.com/questions/2597803

  •  25-09-2019
  •  | 
  •  

Question

Is there any Library for .NET that returns SPARQL results in some structured List instead of standard XML format? I am using SemWeb. I could not find any such method.

Was it helpful?

Solution

SemWeb does appear to provide the building blocks for what you want. Looking at the documentation it seems QueryResultSink is what you want. You could build a list of results using that, or work directly with the results as they arrive.

Alternatively try dotnetrdf. This introduction shows that queries result in a SparqlResultSet that you can iterate through.

From the examples:

TripleStore store = new TripleStore();
// ...data...
Object results = store.ExecuteQuery("SELECT * WHERE {?s ?p ?o}");
if (results is SparqlResultSet) {
    SparqlResultSet rset = (SparqlResultSet)results; 
    foreach (SparqlResult result in rset) { 
        Console.WriteLine(result.ToString());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top