QueryOperator

open class QueryOperator : ObjectBase

Represents a OData query operator. Query operators are typically used within DataQuery.filter. QueryOperatorCall can be constructed using static calls on QueryOperator or, more conveniently, by chained calls on QueryValue.

Example using proxy classes (with QueryOperator static calls)

open func queryOperatorExample() throws -> Void {
    let service = self.service
    let query = DataQuery()
        .filter(QueryOperator.greaterEqual(QueryOperator.multiply(OrderDetail.quantity,
            OrderDetail.unitPrice),
            DecimalValue.of(DecimalFunction.fromInt(1000))))
    let details = try service.fetchOrderDetails(matching: query)
    self.showDetails(details)
}

Example using proxy classes (with QueryValue chained calls)

open func queryValueOperatorExample() throws -> Void {
    let service = self.service
    let query = DataQuery()
        .filter(OrderDetail.quantity.multiply(OrderDetail.unitPrice)
            .greaterEqual(BigDecimal(1000)))
    // Alternate syntax using overloaded operators:
    // let query = DataQuery().filter(OrderDetail.quantity * OrderDetail.unitPrice >= 1000)
    let details = try service.fetchOrderDetails(matching: query)
    self.showDetails(details)
}
  • A map of predefined query operators.

    Declaration

    Swift

    public static let operatorMap: QueryOperatorMap
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Declaration

    Swift

    open class func add(_ left: DataValue, _ right: DataValue) -> QueryValue

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘add’ arithmetic operator.

  • Example using proxy classes

    open func allOperatorExample() throws -> Void {
        let service = self.service
        let p = DataPath.lambda("p")
        let query = DataQuery()
            .filter(Category.products.all(p,
                QueryOperator.greaterThan(p.path(Product.unitPrice), DecimalValue.of(BigDecimal(1)))))
        let categories = try service.fetchCategories(matching: query)
        assert(categories.count != 0)
    }
    

    Example using dynamic API

    open func allOperatorExample() throws -> Void {
        let service = self.service
        let categoriesEntitySet = service.entitySet(withName: "Categories")
        let categoryEntityType = categoriesEntitySet.entityType
        let productsProperty = categoryEntityType.property(withName: "Products")
        let productsEntitySet = service.entitySet(withName: "Products")
        let productEntityType = productsEntitySet.entityType
        let unitPriceProperty = productEntityType.property(withName: "UnitPrice")
        let p = DataPath.lambda("p")
        let query = DataQuery().from(categoriesEntitySet)
            .filter(productsProperty.all(p,
                QueryOperator.greaterThan(p.path(unitPriceProperty), DecimalValue.of(BigDecimal(1)))))
        let categories = try service.executeQuery(query).entityList()
        assert(categories.length != 0)
    }
    

    Declaration

    Swift

    open class func all(_ value: DataValue, lambda: DataPath, match: QueryFilter) -> QueryFilter

    Parameters

    value

    Collection value.

    lambda

    Lambda variable.

    match

    Query filter.

    Return Value

    a deferred call of the OData ‘all’ lambda operator.

  • Declaration

    Swift

    open class func and(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘and’ logical operator.

  • Example using proxy classes

    open func anyOperatorExample() throws -> Void {
        let service = self.service
        let p = DataPath.lambda("p")
        let query = DataQuery()
            .filter(Category.products.any(p,
                QueryOperator.greaterThan(p.path(Product.unitPrice), DecimalValue.of(BigDecimal(20)))))
        let categories = try service.fetchCategories(matching: query)
        assert(categories.count != 0)
    }
    

    Example using dynamic API

    open func anyOperatorExample() throws -> Void {
        let service = self.service
        let categoriesEntitySet = service.entitySet(withName: "Categories")
        let categoryEntityType = categoriesEntitySet.entityType
        let productsProperty = categoryEntityType.property(withName: "Products")
        let productsEntitySet = service.entitySet(withName: "Products")
        let productEntityType = productsEntitySet.entityType
        let unitPriceProperty = productEntityType.property(withName: "UnitPrice")
        let p = DataPath.lambda("p")
        let query = DataQuery().from(categoriesEntitySet)
            .filter(productsProperty.any(p,
                QueryOperator.greaterThan(p.path(unitPriceProperty), DecimalValue.of(BigDecimal(20)))))
        let categories = try service.executeQuery(query).entityList()
        assert(categories.length != 0)
    }
    

    Declaration

    Swift

    open class func any(_ value: DataValue, lambda: DataPath, match: QueryFilter) -> QueryFilter

    Parameters

    value

    Collection value.

    lambda

    Lambda variable.

    match

    Query filter.

    Return Value

    a deferred call of the OData ‘any’ lambda operator.

  • Operator arity (number of arguments).

    Declaration

    Swift

    public final var arity: Int { get }
  • Operator code.

    See also

    QueryOperatorCode.

    Declaration

    Swift

    public final var code: Int { get }
  • Declaration

    Swift

    open class func divide(_ left: DataValue, _ right: DataValue) -> QueryValue

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘div’ arithmetic operator.

  • Declaration

    Swift

    open class func equal(_ left: DataValue?, _ right: DataValue?) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘eq’ logical operator.

  • Lookup a query operator by code.

    See also

    constants.

    Declaration

    Swift

    open class func forCode(_ code: Int) -> QueryOperator

    Parameters

    code

    Operator code.

    Return Value

    Query operator.

  • Lookup a query operator by code.

    Throws

    DataQueryException if name is not the name of a known query operator.

    Declaration

    Swift

    open class func forName(_ name: String) throws -> QueryOperator

    Parameters

    name

    Operator name.

    Return Value

    Query operator.

  • Declaration

    Swift

    open class func greaterEqual(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘ge’ logical operator.

  • Declaration

    Swift

    open class func greaterThan(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘gt’ logical operator.

  • Declaration

    Swift

    open class func has(_ value: DataValue, _ flags: EnumValue) -> QueryFilter

    Parameters

    value

    Enum value to be tested to see if flag is set.

    flags

    Flag(s) to test for.

    Return Value

    a deferred call of the OData ‘has’ operator.

  • Declaration

    Swift

    open class func inList(_ value: DataValue, _ list: DataValue) -> QueryFilter

    Parameters

    value

    Item value to check for membership in list.

    list

    List to check membership within (e.g. a StringList).

    Return Value

    a deferred call of the OData ‘in’ operator.

  • Declaration

    Swift

    open class func lessEqual(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘le’ logical operator.

  • Declaration

    Swift

    open class func lessThan(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘lt’ logical operator.

  • Declaration

    Swift

    open class func modulo(_ left: DataValue, _ right: DataValue) -> QueryValue

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘mod’ arithmetic operator.

  • Declaration

    Swift

    open class func multiply(_ left: DataValue, _ right: DataValue) -> QueryValue

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘mul’ arithmetic operator.

  • Operator name.

    Declaration

    Swift

    public final var name: String { get }
  • Declaration

    Swift

    open class func negate(_ value: DataValue) -> QueryValue

    Parameters

    value

    Numeric value.

    Return Value

    a deferred call of the OData ‘-’ arithmetic operator.

  • Declaration

    Swift

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

    Parameters

    value

    Logical value.

    Return Value

    a deferred call of the OData ‘not’ logical operator.

  • Declaration

    Swift

    open class func notEqual(_ left: DataValue?, _ right: DataValue?) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘ne’ logical operator.

  • Declaration

    Swift

    open class func or(_ left: DataValue, _ right: DataValue) -> QueryFilter

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘or’ logical operator.

  • Operator priority.

    Declaration

    Swift

    public final var priority: Int { get }
  • Declaration

    Swift

    open class func subtract(_ left: DataValue, _ right: DataValue) -> QueryValue

    Parameters

    left

    Left operand.

    right

    Right operand.

    Return Value

    a deferred call of the OData ‘sub’ arithmetic operator.

  • Declaration

    Swift

    override open func toString() -> String

    Return Value

    A string representation of this object.