QueryFilter
open class QueryFilter : DataValue, @unchecked Sendable
Encapsulates the boolean value of an OData logical operator.
Used to wrap the results of logical QueryOperator in a type-safe manner.
Example using proxy classes
open func queryWithFilterExample() throws -> Void {
let service = self.service
let query = DataQuery()
.select(Customer.customerID, Customer.companyName, Customer.contactName)
.filter(Customer.country.equal("Germany")
.and(Customer.contactName.greaterEqual("N")))
// Alternate syntax using convenience operators:
// let query = DataQuery()
// .select(Customer.customerID, Customer.companyName, Customer.contactName)
// .filter(Customer.country == "Germany" && Customer.contactName >= "N")
let customers = try service.fetchCustomers(matching: query)
self.showCustomers(customers)
}
Example using dynamic API
open func queryWithFilterExample() throws -> Void {
let service = self.service
let customersEntitySet = service.entitySet(withName: "Customers")
let customerEntityType = customersEntitySet.entityType
let customerIDProperty = customerEntityType.property(withName: "CustomerID")
let companyNameProperty = customerEntityType.property(withName: "CompanyName")
let contactNameProperty = customerEntityType.property(withName: "ContactName")
let countryProperty = customerEntityType.property(withName: "Country")
let query = DataQuery()
.select(customerIDProperty, companyNameProperty, contactNameProperty)
.from(customersEntitySet)
.filter(countryProperty.equal("Germany")
.and(contactNameProperty.greaterEqual("N")))
// Alternate syntax using convenience operators:
// let query = DataQuery()
// .select(customerIDProperty, companyNameProperty, contactNameProperty)
// .from(customersEntitySet)
// .filter(countryProperty == "Germany" && contactNameProperty >= "N")
let customers = try service.executeQuery(query).entityList()
self.showCustomers(customers)
}
-
Default initializer.
Declaration
Swift
override public init() -
Declaration
Swift
open func and(_ filter: DataValue) -> QueryFilterParameters
filterTo be and'ed with
self.Return Value
An application of the OData ‘and’ logical operator to
selfandfilter. This is a convenience wrapper forQueryOperator.andwhich allows method chaining. -
Declaration
Swift
override open func copyMutable() -> DataValueReturn Value
A clone of this value if it (together with all value subcomponents) is possibly mutable, or return
selfvalue if it (together with all value subcomponents) is definitely immutable. The resulting value might share mutable metadata with this query. -
Data type with a
DataType.codeofDataType.QUERY_FILTER.Declaration
Swift
override open var dataType: DataType { get } -
See also
QueryOperatorCode.Parameters
propertyProperty to match.
operatorCodeOperator to match.
Return Value
A top-level comparison value for the specified property and operator. Otherwise
nil. If this filter contains a top-level (possibly and'ed) condition for the specified property and operator, then return the comparison value. -
Construct a query filter by wrapping a boolean value, so it can be used by
DataQuery.queryFilterorDataQuery.where.Declaration
Swift
open class func from(_ value: DataValue) -> QueryFilterParameters
valueA boolean value.
Return Value
A new query filter.
-
Declaration
Swift
open func not() -> QueryFilterReturn Value
An application of the OData ‘not’ logical operator to
self. This is a convenience wrapper forQueryOperator.notwhich allows method chaining. -
Declaration
Swift
open func or(_ filter: DataValue) -> QueryFilterParameters
filterTo be or'ed with
self.Return Value
An application of the OData ‘or’ logical operator to
selfandfilter. This is a convenience wrapper forQueryOperator.orwhich allows method chaining. -
Convert this data value to a string. If the
dataTypeis defined by XML Schema Part 2: Datatypes, then the corresponding lexical format is used. JSON format is used for structured values (arrays and objects).Declaration
Swift
override open func toString() -> StringReturn Value
Lexical representation of this data value.
-
The wrapped value which is expected to resolve to a boolean value during query execution.
Declaration
Swift
public final var value: DataValue { get set }