Class DataSourceApiQuery
Namespace: Casewhere.Runtime.DSL.Api
Assembly: Casewhere.Runtime.dll
Represents the ActualData Object query which is performed on Casewhere DataSource.
public class DataSourceApiQuery : DataApiQuery
Inheritance
object ← DataApiQuery ← DataSourceApiQuery
Inherited Members
DataApiQuery.Filter, DataApiQuery.ProjectedFields, DataApiQuery.SortedFields, DataApiQuery.Take, DataApiQuery.Skip, DataApiQuery.SearchLimit, DataApiQuery.IncludeTotal, DataApiQuery.GeoSpatialStages, DataApiQuery.CustomCollation, DataApiQuery.HintIndexName, DataApiQuery.HintIndexForCount, DataApiQuery.MaxQueryTimeout, object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()
Extension Methods
ObjectExtension.ConvertToBsonValue(object), EnumExtensions.DeepClone<DataSourceApiQuery>(DataSourceApiQuery)
Examples
var filter = FilterBuilder.Create().Eq("DepartmentId", ctx.Input.Id).Eq("Active", true).Build();
var query = DataSourceApiQuery.For("EmployeeWithDepartments")
.FilterBy(filter)
.ProjectOn("Username", "Department")
.OrderBy("Firstname", true)
.Paging(0, 10);
var result = ctx.Use<IDataApi>().Search(query);
Properties
DataSourceName
The ActualData Source name.
public string DataSourceName { get; set; }
Property Value
DataSourceParameters
The Parameters that passed to the data source query.
public Dictionary<string, object> DataSourceParameters { get; set; }
Property Value
Methods
FilterBy(DynamicFilter)
Set query filter. For chaining purpose.
public DataSourceApiQuery FilterBy(DynamicFilter filter)
Parameters
filter
DynamicFilter
The filter.
Returns
The query object itself for chaining purpose.
FilterBy(object)
Set query filter. For chaining purpose.
public DataSourceApiQuery FilterBy(object filter)
Parameters
filter
object
The filter.
Returns
The query object itself for chaining purpose.
For(string)
Creates the query object.
public static DataSourceApiQuery For(string dataSourceName)
Parameters
dataSourceName
string
The ActualData Source name.
Returns
The query object.
GeoNear(string, GeoJsonObject, double?, double?)
Create a geospatial queries that find documents near a specific location, taking distance constraints into account.
public DataSourceApiQuery GeoNear(string field, GeoJsonObject value, double? maxDistance = 0, double? minDistance = 0)
Parameters
field
string
This parameter specifies the name of the field in your documents that contains location data or coordinates.
value
GeoJsonObject
A GeoJsonObject geometry for use with the following geospatial query operators.
maxDistance
double?
This parameter specifies the maximum distance within which to find documents. It defaults to 0 if not provided.
minDistance
double?
This parameter specifies the minimum distance from the target location. It defaults to 0 if not provided.
Returns
The query object itself for chaining purpose.
GeoNearSphere(string, GeoJsonObject, double?, double?)
Create a geospatial query for finding documents near a specific geographic location, emphasizing spherical calculations.
public DataSourceApiQuery GeoNearSphere(string field, GeoJsonObject value, double? maxDistance = 0, double? minDistance = 0)
Parameters
field
string
This parameter specifies the name of the field in your documents that contains location data or coordinates.
value
GeoJsonObject
A GeoJsonObject geometry for use with the following geospatial query operators.
maxDistance
double?
This parameter specifies the maximum distance within which to find documents. It defaults to 0 if not provided.
minDistance
double?
This parameter specifies the minimum distance from the target location. It defaults to 0 if not provided.
Returns
The query object itself for chaining purpose.
IncludeTotalItems(bool)
Determines whether Casewhere returns the total number of ActualData Objects. For chaining purpose.
public DataSourceApiQuery IncludeTotalItems(bool include)
Parameters
include
bool
True means include.
Returns
The query object itself for chaining purpose.
Near(string, double, double, double?, double?)
Create a geospatial queries that find documents near a specific location, taking distance constraints into account.
public DataSourceApiQuery Near(string field, double x, double y, double? maxDistance = 0, double? minDistance = 0)
Parameters
field
string
This parameter specifies the name of the field in your documents that contains location data or coordinates.
x
double
The parameter represent the longitude.
y
double
The parameter represent the latitude.
maxDistance
double?
This parameter specifies the maximum distance within which to find documents. It defaults to 0 if not provided.
minDistance
double?
This parameter specifies the minimum distance from the target location. It defaults to 0 if not provided.
Returns
The query object itself for chaining purpose.
NearSphere(string, double, double, double?, double?)
Create a geospatial query for finding documents near a specific geographic location, emphasizing spherical calculations.
public DataSourceApiQuery NearSphere(string field, double x, double y, double? maxDistance = 0, double? minDistance = 0)
Parameters
field
string
This parameter specifies the name of the field in your documents that contains location data or coordinates.
x
double
The parameter represent the longitude.
y
double
The parameter represent the latitude.
maxDistance
double?
This parameter specifies the maximum distance within which to find documents. It defaults to 0 if not provided.
minDistance
double?
This parameter specifies the minimum distance from the target location. It defaults to 0 if not provided.
Returns
The query object itself for chaining purpose.
OrderBy(string, bool)
Set query sorting. For chaining purpose.
public DataSourceApiQuery OrderBy(string name, bool asc = true)
Parameters
name
string
The field name.
asc
bool
Ascending or Descending.
Returns
The query object itself for chaining purpose.
Paging(int, int)
Set query paging. For chaining purpose.
public DataSourceApiQuery Paging(int skip = 0, int take = 0)
Parameters
skip
int
The number of ActualData Objects bypassed.
take
int
The number of ActualData Objects returned.
Returns
The query object itself for chaining purpose.
ProjectOn(params string[])
Set query projection. For chaining purpose.
public DataSourceApiQuery ProjectOn(params string[] fieldNames)
Parameters
fieldNames
string[]
The projection.
Returns
The query object itself for chaining purpose.
SetHintIndex(string)
Specify a hint index name for this query.
public DataSourceApiQuery SetHintIndex(string hintIndexName)
Parameters
hintIndexName
string
The hint index name
Returns
The query object itself for chaining purpose.
SetHintIndexForCount(string)
Specify a hint index name for this counting query.
public DataSourceApiQuery SetHintIndexForCount(string hintIndexForCount)
Parameters
hintIndexForCount
string
The hint index name
Returns
The query object itself for chaining purpose.
SetMaxQueryTimeout(int)
Specify max timeout for this query.
public DataSourceApiQuery SetMaxQueryTimeout(int maxQueryTimeout)
Parameters
maxQueryTimeout
int
The max query timeout
Returns
The query object itself for chaining purpose.
SetParameter(string, object)
Add a parameter into the parameters of the query.
public DataSourceApiQuery SetParameter(string key, object value)
Parameters
key
string
Key of the parameter that added into the parameters of data source query.
value
object
Value of the parameter that added into the parameters of data source query.
Returns
The query object itself for chaining purpose.
SetParameters(Dictionary<string, object>)
Set parameters for the query.
public DataSourceApiQuery SetParameters(Dictionary<string, object> parameters)
Parameters
parameters
Dictionary<string, object>
Specify the parameters that passed to the data source query.
Returns
The query object itself for chaining purpose.
ToRuntimeQuery()
Convert DataSourceApiQuery to PagedDataSourceQuery. Ensure ProjectedFields has Id.
public virtual PagedDataSourceQuery ToRuntimeQuery()
Returns
Converted PagedDataSourceQuery from DataSourceApiQuery.
WithCustomCollation(string, int)
Specify a custom collation for this query. If not specified, the data source's collation will be used, if not specified too, the default collation will be used.
public DataSourceApiQuery WithCustomCollation(string collationLocale, int collationStrength)
Parameters
collationLocale
string
This parameter specifies the locale of the custom collation.
collationStrength
int
This parameter specifies the strengh of the custom collation.
Returns
The query object itself for chaining purpose.