Show / Hide Table of Contents

Class SparqlQueryClient

A class for connecting to a remote SPARQL endpoint and making queries against it using the System.Net.Http library.

Inheritance
object
SparqlQueryClient
Implements
ISparqlQueryClient
IConfigurationSerializable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: VDS.RDF.Query
Assembly: dotNetRdf.dll
Syntax
public class SparqlQueryClient : ISparqlQueryClient, IConfigurationSerializable

Constructors

| Edit this page View Source

SparqlQueryClient(HttpClient, Uri)

Create a new SPARQL client.

Declaration
public SparqlQueryClient(HttpClient httpClient, Uri endpointUri)
Parameters
Type Name Description
HttpClient httpClient

The underlying client to use for HTTP requests.

Uri endpointUri

The URI of the SPARQL endpoint to connect to.

Properties

| Edit this page View Source

DefaultGraphs

Gets the Default Graph URIs for Queries made to the SPARQL Endpoint.

Declaration
public List<string> DefaultGraphs { get; }
Property Value
Type Description
List<string>
| Edit this page View Source

EndpointUri

Gets the URI of the remote SPARQL endpoint.

Declaration
public Uri EndpointUri { get; }
Property Value
Type Description
Uri
| Edit this page View Source

HttpMode

Get or set the mode used to determine the HTTP method to be used by the client.

Declaration
public HttpMode HttpMode { get; set; }
Property Value
Type Description
HttpMode
Remarks

The default mode is Auto which uses a GET unless the SPARQL query is too long or contains characters that cannot be encoded as an HTTP query string, in which case POST is used.

| Edit this page View Source

NamedGraphs

Gets the List of Named Graphs used in requests.

Declaration
public List<string> NamedGraphs { get; }
Property Value
Type Description
List<string>
| Edit this page View Source

RdfAcceptHeader

Gets/Sets the Accept Header sent with CONSTRUCT/DESCRIBE queries.

Declaration
public string RdfAcceptHeader { get; set; }
Property Value
Type Description
string
Remarks

Can be used to workaround buggy endpoints which don't like the broad Accept Header that dotNetRDF sends by default. If not set or explicitly set to null the library uses the default header generated by HttpAcceptHeader.

| Edit this page View Source

ResultsAcceptHeader

Gets/Sets the Accept Header sent with ASK/SELECT queries.

Declaration
public string ResultsAcceptHeader { get; set; }
Property Value
Type Description
string
Remarks

Can be used to workaround buggy endpoints which don't like the broad Accept Header that dotNetRDF sends by default. If not set or explicitly set to null the library uses the default header generated by HttpSparqlAcceptHeader.

Methods

| Edit this page View Source

QueryAsync(string, IRdfHandler, ISparqlResultsHandler, CancellationToken)

Execute a SPARQL query.

Declaration
public Task QueryAsync(string sparqlQuery, IRdfHandler graphHandler, ISparqlResultsHandler resultsHandler, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

IRdfHandler graphHandler

The handler to use when paring graph results from a CONSTRUCT or DESCRIBE query.

ISparqlResultsHandler resultsHandler

The handler to sue when parsing SPARQL results sets from a SELECT or ASK query.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task
| Edit this page View Source

QueryInternal(string, string, CancellationToken)

Internal method which builds and executes the query as a GET or POST as appropriate.

Declaration
protected Task<HttpResponseMessage> QueryInternal(string sparqlQuery, string acceptHeader, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The SPARQL query string.

string acceptHeader

The value to insert into the Accept header of the outgoing HTTP request.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<HttpResponseMessage>
| Edit this page View Source

QueryWithResultGraphAsync(string)

Execute a SPARQL query that is intended to return an RDF Graph.

Declaration
public Task<IGraph> QueryWithResultGraphAsync(string sparqlQuery)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

Returns
Type Description
Task<IGraph>

An RDF Graph.

Remarks

This method should be used when processing SPARQL CONSTRUCT or DESCRIBE queries.

| Edit this page View Source

QueryWithResultGraphAsync(string, CancellationToken)

Execute a SPARQL query that is intended to return an RDF Graph.

Declaration
public Task<IGraph> QueryWithResultGraphAsync(string sparqlQuery, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<IGraph>

An RDF Graph.

Remarks

This method should be used when processing SPARQL CONSTRUCT or DESCRIBE queries.

| Edit this page View Source

QueryWithResultGraphAsync(string, IRdfHandler)

Execute a SPARQL query that is intended to return an RDF Graph.

Declaration
public Task QueryWithResultGraphAsync(string sparqlQuery, IRdfHandler handler)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

IRdfHandler handler

The handler to use when parsing the graph data returned by the server.

Returns
Type Description
Task

An RDF Graph.

Remarks

This method should be used when processing SPARQL CONSTRUCT or DESCRIBE queries.

| Edit this page View Source

QueryWithResultGraphAsync(string, IRdfHandler, CancellationToken)

Execute a SPARQL query that is intended to return an RDF Graph.

Declaration
public Task QueryWithResultGraphAsync(string sparqlQuery, IRdfHandler handler, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

IRdfHandler handler

The handler to use when parsing the graph data returned by the server.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task

An RDF Graph.

Remarks

This method should be used when processing SPARQL CONSTRUCT or DESCRIBE queries.

| Edit this page View Source

QueryWithResultSetAsync(string)

Execute a SPARQL query that is intended to return a SPARQL results set.

Declaration
public Task<SparqlResultSet> QueryWithResultSetAsync(string sparqlQuery)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

Returns
Type Description
Task<SparqlResultSet>

The query results.

Remarks

This method should be used when processing SPARQL SELECT or ASK queries.

| Edit this page View Source

QueryWithResultSetAsync(string, CancellationToken)

Execute a SPARQL query that is intended to return a SPARQL results set.

Declaration
public Task<SparqlResultSet> QueryWithResultSetAsync(string sparqlQuery, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<SparqlResultSet>

The query results.

Remarks

This method should be used when processing SPARQL SELECT or ASK queries.

| Edit this page View Source

QueryWithResultSetAsync(string, ISparqlResultsHandler)

Execute a SPARQL query that is intended to return a SPARQL results set.

Declaration
public Task QueryWithResultSetAsync(string sparqlQuery, ISparqlResultsHandler resultsHandler)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

ISparqlResultsHandler resultsHandler

The handler to use when parsing the results returned by the server.

Returns
Type Description
Task

The query results.

Remarks

This method should be used when processing SPARQL SELECT or ASK queries.

| Edit this page View Source

QueryWithResultSetAsync(string, ISparqlResultsHandler, CancellationToken)

Execute a SPARQL query that is intended to return a SPARQL results set.

Declaration
public Task QueryWithResultSetAsync(string sparqlQuery, ISparqlResultsHandler resultsHandler, CancellationToken cancellationToken)
Parameters
Type Name Description
string sparqlQuery

The query to be executed.

ISparqlResultsHandler resultsHandler

The handler to use when parsing the results returned by the server.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task

The query results.

Remarks

This method should be used when processing SPARQL SELECT or ASK queries.

| Edit this page View Source

SerializeConfiguration(ConfigurationSerializationContext)

Serializes the Endpoint's Configuration.

Declaration
public void SerializeConfiguration(ConfigurationSerializationContext context)
Parameters
Type Name Description
ConfigurationSerializationContext context

Configuration Serialization Context.

Implements

ISparqlQueryClient
IConfigurationSerializable

Extension Methods

Extensions.ToSafeString(object)
Extensions.AsEnumerable<T>(T)
  • Edit this page
  • View Source
In this article
  • Constructors
    • SparqlQueryClient(HttpClient, Uri)
  • Properties
    • DefaultGraphs
    • EndpointUri
    • HttpMode
    • NamedGraphs
    • RdfAcceptHeader
    • ResultsAcceptHeader
  • Methods
    • QueryAsync(string, IRdfHandler, ISparqlResultsHandler, CancellationToken)
    • QueryInternal(string, string, CancellationToken)
    • QueryWithResultGraphAsync(string)
    • QueryWithResultGraphAsync(string, CancellationToken)
    • QueryWithResultGraphAsync(string, IRdfHandler)
    • QueryWithResultGraphAsync(string, IRdfHandler, CancellationToken)
    • QueryWithResultSetAsync(string)
    • QueryWithResultSetAsync(string, CancellationToken)
    • QueryWithResultSetAsync(string, ISparqlResultsHandler)
    • QueryWithResultSetAsync(string, ISparqlResultsHandler, CancellationToken)
    • SerializeConfiguration(ConfigurationSerializationContext)
  • Implements
  • Extension Methods
Back to top Generated by DocFX