QueryFilter

open class QueryFilter : DataValue

Encapsulates the boolean value of an OData logical operator. Used to wrap the results of logical QueryOperator in a type-safe manner.

See also

DataQuery.queryFilter, DataQuery.filter.

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) -> QueryFilter

    Parameters

    filter

    To be and'ed with self.

    Return Value

    An application of the OData ‘and’ logical operator to self and filter. This is a convenience wrapper for QueryOperator.and which allows method chaining.

  • Data type with a DataType.code of DataType.QUERY_FILTER.

    Declaration

    Swift

    override open var dataType: DataType { get }
  • See also

    QueryOperatorCode.

    Declaration

    Swift

    open func find(property: Property, operatorCode: Int) -> DataValue?

    Parameters

    property

    Property to match.

    operatorCode

    Operator 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.queryFilter or DataQuery.where.

    Declaration

    Swift

    open class func from(_ value: DataValue) -> QueryFilter

    Parameters

    value

    A boolean value.

    Return Value

    A new query filter.

  • Declaration

    Swift

    open func not() -> QueryFilter

    Return Value

    An application of the OData ‘not’ logical operator to self. This is a convenience wrapper for QueryOperator.not which allows method chaining.

  • Declaration

    Swift

    open func or(_ filter: DataValue) -> QueryFilter

    Parameters

    filter

    To be or'ed with self.

    Return Value

    An application of the OData ‘or’ logical operator to self and filter. This is a convenience wrapper for QueryOperator.or which allows method chaining.

  • Convert this data value to a string. If the dataType is 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() -> String

    Return 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 }