corelibraries-devexpress-dot-dataaccess-dot-json-4d23c0e2.md
A parameter that is used to pass HTTP request parameter values to a JSON endpoint.
Namespace : DevExpress.DataAccess.Json
Assembly : DevExpress.DataAccess.v25.2.dll
NuGet Package : DevExpress.DataAccess
public class QueryParameter :
DataSourceParameterBase
Public Class QueryParameter
Inherits DataSourceParameterBase
The following members return QueryParameter objects:
Use query parameters to pass HTTP request parameters to a JSON endpoint.
| URI Example | Notes |
|---|---|
| http: //www.example.com/api/orders/? startDate =2019-01-01& endDate =2019-12-31 | Use query parameters to specify the startDate and endDate. |
Add query parameters to QueryParameterCollection and assign the collection to the UriJsonSource.QueryParameters property.
The parameters are added to endpoint requests in the same order they occupy in the collection. Change the order of elements in the collection to reposition parameters in endpoint requests.
Specify the following properties to configure a query parameter:
You can use expressions to set the query parameter value. Specify an expression in the parameter’s Value property and specify that the parameter’s Type is DevExpress.DataAccess.Expression. In DevExpress reports, expressions can include report parameters. Prepend the report parameter’s name with the ? character in an expression:
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
Uri = new Uri(@"https://localhost:44367/api/values")
};
// Create the "date" and "id" query parameters that are appended to the JSON URI: https://localhost:44367/api/values/?date=2020-01-15&id=123.
jsonSource.QueryParameters.AddRange(new[] {
new QueryParameter("date", typeof(String), String.Format("{0:yyyy-MM-dd}", DateTime.Today)),
// "ID" is a report parameter whose value is used for the "id" query parameter.
new QueryParameter("id", typeof(Expression), new Expression("?ID"))
});
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
JsonSource = jsonSource
};
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON source.
Dim jsonSource = New UriJsonSource() With {.Uri = New Uri("https://localhost:44367/api/values")}
' Create the "date" and "id" query parameters that are appended to the JSON URI: https://localhost:44367/api/values/?date=2020-01-15&id=123.
jsonSource.QueryParameters.AddRange( {
New QueryParameter("date", GetType(String), String.Format("{0:yyyy-MM-dd}", Date.Today)),
New QueryParameter("id", GetType(Expression), New Expression("?ID"))
})
' "ID" is a report parameter whose value is used for the "id" query parameter.
' Assign the JSON source to the data source.
Dim datasource = New JsonDataSource() With {.JsonSource = jsonSource}
The code sample below specifies a JSON endpoint and uses the date and id query parameters to identify the data record requested from the endpoint. The id query parameter is bound to the ID report parameter.
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
Uri = new Uri(@"https://localhost:44367/api/values")
};
// Create the "date" and "id" query parameters that are appended to the JSON URI: https://localhost:44367/api/values/?date=2020-01-15&id=123.
jsonSource.QueryParameters.AddRange(new[] {
new QueryParameter("date", typeof(String), String.Format("{0:yyyy-MM-dd}", DateTime.Today)),
// "ID" is a report parameter whose value is used for the "id" query parameter.
new QueryParameter("id", typeof(Expression), new Expression("?ID"))
});
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
JsonSource = jsonSource
};
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON source.
Dim jsonSource = New UriJsonSource() With {.Uri = New Uri("https://localhost:44367/api/values")}
' Create the "date" and "id" query parameters that are appended to the JSON URI: https://localhost:44367/api/values/?date=2020-01-15&id=123.
jsonSource.QueryParameters.AddRange( {
New QueryParameter("date", GetType(String), String.Format("{0:yyyy-MM-dd}", Date.Today)),
New QueryParameter("id", GetType(Expression), New Expression("?ID"))
})
' "ID" is a report parameter whose value is used for the "id" query parameter.
' Assign the JSON source to the data source.
Dim datasource = New JsonDataSource() With {.JsonSource = jsonSource}
Object DataSourceParameterBase QueryParameter
See Also