# CSSelectTerm Class Reference

# CSSelectTerm

    @objc
    public final class CSSelectTerm : NSObject

The `CSSelectTerm` serves as the Objective-C bridging type for `SelectTerm`.

See also

`SelectTerm`

- `init(keyPath:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying an entity attribute.

      NSString *fullName = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:CSSelectString(CSAttribute(@"fullname"))
          fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];

  #### Declaration

  Swift

      @objc
      public convenience init(keyPath: KeyPathString)

  #### Parameters

  `keyPath` | the attribute name

- `average(_:as:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute.

      NSNumber *averageAge = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect numberForTerm:[CSSelectTerm average:@"age" as:nil]]];

  #### Declaration

  Swift

      @objc
      public static func average(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm

  #### Parameters

  `keyPath` | the attribute name

  #### Return Value

  a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute

- `count(_:as:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for a count query.

      NSNumber *numberOfEmployees = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect numberForTerm:[CSSelectTerm count:@"employeeID" as:nil]]];

  #### Declaration

  Swift

      @objc
      public static func count(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm

  #### Parameters

  `keyPath` | the attribute name
  `alias` | the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key count(<attributeName>) is used

  #### Return Value

  a `SelectTerm` to a `Select` clause for a count query

- `maximum(_:as:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute.

      NSNumber *maximumAge = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect numberForTerm:[CSSelectTerm maximum:@"age" as:nil]]];

  #### Declaration

  Swift

      @objc
      public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm

  #### Parameters

  `keyPath` | the attribute name
  `alias` | the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key max(<attributeName>) is used

  #### Return Value

  a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute

- `minimum(_:as:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute.

      NSNumber *minimumAge = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect numberForTerm:[CSSelectTerm minimum:@"age" as:nil]]];

  #### Declaration

  Swift

      @objc
      public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm

  #### Parameters

  `keyPath` | the attribute name
  `alias` | the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key min(<attributeName>) is used

  #### Return Value

  a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute

- `sum(_:as:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute.

      NSNumber *totalAge = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect numberForTerm:[CSSelectTerm sum:@"age" as:nil]]];

  #### Declaration

  Swift

      @objc
      public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm

  #### Parameters

  `keyPath` | the attribute name
  `alias` | the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key sum(<attributeName>) is used

  #### Return Value

  a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute

- `objectIDAs(_:)`

  Provides a `CSSelectTerm` to a `CSSelect` clause for querying the `NSManagedObjectID`.

      NSManagedObjectID *objectID = [CSCoreStore
          queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
          select:[CSSelect objectIDForTerm:[CSSelectTerm objectIDAs:nil]]
          fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];

  #### Declaration

  Swift

      @objc
      public static func objectIDAs(_ alias: KeyPathString? = nil) -> CSSelectTerm

  #### Parameters

  `alias` | the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key objecID is used

  #### Return Value

  a `SelectTerm` to a `Select` clause for querying the sum value for an attribute