Class QueryBuilder
Provides methods for building queries with a fluent style API.
Inheritance
Implements
Inherited Members
Namespace: VDS.RDF.Query.Builder
Assembly: dotNetRdf.dll
Syntax
public class QueryBuilder : IQueryBuilder
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Constructors
| Improve this Doc View SourceQueryBuilder(SparqlQueryType)
Create a new query builder for a specific type of SPARQL query.
Declaration
protected QueryBuilder(SparqlQueryType sparqlQueryType)
Parameters
Type | Name | Description |
---|---|---|
SparqlQueryType | sparqlQueryType | The type of SPARQL query to build. |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Properties
| Improve this Doc View SourcePrefixes
Gets or sets the namespace mappings for the SPARQL query being built.
Declaration
public INamespaceMapper Prefixes { get; set; }
Property Value
Type | Description |
---|---|
INamespaceMapper |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
QueryType
Gets the query type of the generated SPARQL query.
Declaration
public SparqlQueryType QueryType { get; protected set; }
Property Value
Type | Description |
---|---|
SparqlQueryType |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Root
Gets the builder associated with the root graph pattern.
Declaration
public IGraphPatternBuilder Root { get; }
Property Value
Type | Description |
---|---|
IGraphPatternBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
RootGraphPatternBuilder
Gets the builder associated with the root graph pattern.
Declaration
public GraphPatternBuilder RootGraphPatternBuilder { get; }
Property Value
Type | Description |
---|---|
GraphPatternBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Methods
| Improve this Doc View SourceAsk()
Creates a new ASK query.
Declaration
public static IQueryBuilder Ask()
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Bind(Func<INonAggregateExpressionBuilder, SparqlExpression>)
Adds a BIND variable assignment to the root graph pattern.
Declaration
public IAssignmentVariableNamePart<IQueryBuilder> Bind(Func<INonAggregateExpressionBuilder, SparqlExpression> buildAssignmentExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><INonAggregateExpressionBuilder, SparqlExpression> | buildAssignmentExpression |
Returns
Type | Description |
---|---|
IAssignmentVariableNamePart<IQueryBuilder> |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
BuildQuery()
Builds and returns a SparqlQuery.
Declaration
public SparqlQuery BuildQuery()
Returns
Type | Description |
---|---|
SparqlQuery |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
BuildQuery(SparqlQuery)
Performs the internal build process for a SparqlQuery.
Declaration
protected virtual SparqlQuery BuildQuery(SparqlQuery query)
Parameters
Type | Name | Description |
---|---|---|
SparqlQuery | query | The query to be processed. |
Returns
Type | Description |
---|---|
SparqlQuery |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Construct()
Creates a new CONSTRUCT WHERE query.
Declaration
public static IQueryBuilder Construct()
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Construct(Action<IDescribeGraphPatternBuilder>)
Creates a new CONSTRUCT query.
Declaration
public static IQueryBuilder Construct(Action<IDescribeGraphPatternBuilder> buildConstructTemplate)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T><IDescribeGraphPatternBuilder> | buildConstructTemplate |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Describe(params string[])
Creates a new query, which will DESCRIBE the given variables
.
Declaration
public static IDescribeBuilder Describe(params string[] variables)
Parameters
Type | Name | Description |
---|---|---|
string[] | variables |
Returns
Type | Description |
---|---|
IDescribeBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Describe(params Uri[])
Creates a new query, which will DESCRIBE the given uris
.
Declaration
public static IDescribeBuilder Describe(params Uri[] uris)
Parameters
Type | Name | Description |
---|---|---|
System.Uri[] | uris |
Returns
Type | Description |
---|---|
IDescribeBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
GroupBy(Func<INonAggregateExpressionBuilder, SparqlExpression>)
Adds a GROUP BY clause to the query.
Declaration
public IQueryBuilder GroupBy(Func<INonAggregateExpressionBuilder, SparqlExpression> buildGroupingExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><INonAggregateExpressionBuilder, SparqlExpression> | buildGroupingExpression |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
GroupBy(string)
Adds a GROUP BY clause to the query.
Declaration
public IQueryBuilder GroupBy(string variableName)
Parameters
Type | Name | Description |
---|---|---|
string | variableName |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
GroupBy(SparqlVariable)
Adds a GROUP BY clause to the query.
Declaration
public IQueryBuilder GroupBy(SparqlVariable variable)
Parameters
Type | Name | Description |
---|---|---|
SparqlVariable | variable |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Having(Func<IExpressionBuilder, BooleanExpression>)
Adds a HAVING clause to the query.
Declaration
public IQueryBuilder Having(Func<IExpressionBuilder, BooleanExpression> buildHavingConstraint)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><IExpressionBuilder, BooleanExpression> | buildHavingConstraint |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
InlineDataOverQuery(params string[])
Adds a VALUES inline data block to the entire query (outside graph patterns).
Declaration
public IInlineDataBuilder InlineDataOverQuery(params string[] variables)
Parameters
Type | Name | Description |
---|---|---|
string[] | variables |
Returns
Type | Description |
---|---|
IInlineDataBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Limit(int)
Applies a LIMIT.
Declaration
public IQueryBuilder Limit(int limit)
Parameters
Type | Name | Description |
---|---|---|
int | limit | Limit value. Pass negative to disable LIMIT. |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Offset(int)
Applies an OFFSET.
Declaration
public IQueryBuilder Offset(int offset)
Parameters
Type | Name | Description |
---|---|---|
int | offset |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderBy(Func<IExpressionBuilder, SparqlExpression>)
Adds ascending ordering by an expression to the query.
Declaration
public IQueryBuilder OrderBy(Func<IExpressionBuilder, SparqlExpression> buildOrderExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><IExpressionBuilder, SparqlExpression> | buildOrderExpression |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderBy(string)
Adds ascending ordering by a variable to the query.
Declaration
public IQueryBuilder OrderBy(string variableName)
Parameters
Type | Name | Description |
---|---|---|
string | variableName |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderBy(SparqlVariable)
Adds ascending ordering by a variable to the query.
Declaration
public IQueryBuilder OrderBy(SparqlVariable variable)
Parameters
Type | Name | Description |
---|---|---|
SparqlVariable | variable |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderByDescending(Func<IExpressionBuilder, SparqlExpression>)
Adds descending ordering by an expression to the query.
Declaration
public IQueryBuilder OrderByDescending(Func<IExpressionBuilder, SparqlExpression> buildOrderExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><IExpressionBuilder, SparqlExpression> | buildOrderExpression |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderByDescending(string)
Adds descending ordering by a variable to the query.
Declaration
public IQueryBuilder OrderByDescending(string variableName)
Parameters
Type | Name | Description |
---|---|---|
string | variableName |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
OrderByDescending(SparqlVariable)
Adds descending ordering by a variable to the query.
Declaration
public IQueryBuilder OrderByDescending(SparqlVariable variable)
Parameters
Type | Name | Description |
---|---|---|
SparqlVariable | variable |
Returns
Type | Description |
---|---|
IQueryBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Select(params string[])
Creates a new SELECT query which will return the given
variables
.
Declaration
public static ISelectBuilder Select(params string[] variables)
Parameters
Type | Name | Description |
---|---|---|
string[] | variables | query result variables. |
Returns
Type | Description |
---|---|
ISelectBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Select(params SparqlVariable[])
Creates a new SELECT query which will return the given
variables
.
Declaration
public static ISelectBuilder Select(params SparqlVariable[] variables)
Parameters
Type | Name | Description |
---|---|---|
SparqlVariable[] | variables | query result variables. |
Returns
Type | Description |
---|---|
ISelectBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
Select<TExpression>(Func<IExpressionBuilder, PrimaryExpression<TExpression>>)
Creates a new SELECT query which will return an expression.
Declaration
public static IAssignmentVariableNamePart<ISelectBuilder> Select<TExpression>(Func<IExpressionBuilder, PrimaryExpression<TExpression>> buildAssignmentExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><IExpressionBuilder, PrimaryExpression<TExpression>> | buildAssignmentExpression |
Returns
Type | Description |
---|---|
IAssignmentVariableNamePart<ISelectBuilder> |
Type Parameters
Name | Description |
---|---|
TExpression |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.
SelectAll()
Creates a new SELECT * query.
Declaration
public static ISelectBuilder SelectAll()
Returns
Type | Description |
---|---|
ISelectBuilder |
Remarks
A SparqlQuery is mutable by definition so calling any of the extension methods in this API will cause the existing query it is called on to be changed. You can call Copy() on an existing query to create a new copy if you want to make different queries starting from the same base query.