# Select

    public struct Select<O, T> : SelectClause, Hashable where O : DynamicObject, T : SelectResultType

    extension Select: CustomDebugStringConvertible, CoreStoreDebugStringConvertible

The `Select` clause indicates the attribute / aggregate value to be queried. The generic type is a `SelectResultType`, and will be used as the return type for the query.

You can bind the return type by specializing the initializer:

    let maximumAge = dataStack.queryValue(
        From<MyPersonEntity>(),
        Select<Int>(.maximum("age"))
    )

or by casting the type of the return value:

    let maximumAge: Int = dataStack.queryValue(
        From<MyPersonEntity>(),
        Select(.maximum("age"))
    )

Valid return types depend on the query:

- for `queryValue(...)` methods:
  - all types that conform to `QueryableAttributeType` protocol

- for `queryAttributes(...)` methods:

  - `NSDictionary`

#### Parameters

`sortDescriptors` | a series of `NSSortDescriptor`s

- `init(_:_:)`

  Initializes a `Select` clause with a list of `SelectTerm`s

  #### Declaration

  Swift

      public init(_ selectTerm: SelectTerm<O>, _ selectTerms: SelectTerm<O>...)

  #### Parameters

  `selectTerm` | a `SelectTerm`
  `selectTerms` | a series of `SelectTerm`s

- `init(_:)`

  Initializes a `Select` clause with a list of `SelectTerm`s

  #### Declaration

  Swift

      public init(_ selectTerms: [SelectTerm<O>])

  #### Parameters

  `selectTerms` | a series of `SelectTerm`s

### Equatable

- `==(_:_:)`

  #### Declaration

  Swift

      public static func == <T1, T2>(lhs: Select<O, T1>, rhs: Select<O, T2>) -> Bool where T1 : SelectResultType, T2 : SelectResultType

### SelectClause

- `ObjectType`

  #### Declaration

  Swift

      public typealias ObjectType = O

- `ReturnType`

  #### Declaration

  Swift

      public typealias ReturnType = T

- `selectTerms`

  #### Declaration

  Swift

      public let selectTerms: [SelectTerm<O>]

### Hashable

- `hash(into:)`

  #### Declaration

  Swift

      public func hash(into hasher: inout Hasher)

### CustomDebugStringConvertible

- `debugDescription`

  #### Declaration

  Swift

      public var debugDescription: String { get }

### Available where `T`: `NSManagedObjectID`

- `init()`

  Initializes a `Select` that queries for `NSManagedObjectID` results

  #### Declaration

  Swift

      public init()

### Available where `O`: `NSManagedObject`

- `init(_:)`

  Initializes a `Select` that queries the value of an attribute pertained by a keyPath

  #### Declaration

  Swift

      public init(_ keyPath: KeyPath<O, T>)

  #### Parameters

  `keyPath` | the keyPath for the attribute

### Available where `O`: `CoreStoreObject`, `T`: `ImportableAttributeType`

- `init(_:)`

  Initializes a `Select` that queries the value of an attribute pertained by a keyPath

  #### Declaration

  Swift

      public init(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>)

  #### Parameters

  `keyPath` | the keyPath for the attribute

- `init(_:)`

  Initializes a `Select` that queries the value of an attribute pertained by a keyPath

  #### Declaration

  Swift

      public init(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>)

  #### Parameters

  `keyPath` | the keyPath for the attribute

### Available where `O`: `CoreStoreObject`, `T`: `ImportableAttributeType` & `NSCoding` & `NSCopying`

- `init(_:)`

  Initializes a `Select` that queries the value of an attribute pertained by a keyPath

  #### Declaration

  Swift

      public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>)

  #### Parameters

  `keyPath` | the keyPath for the attribute

- `init(_:)`

  Initializes a `Select` that queries the value of an attribute pertained by a keyPath

  #### Declaration

  Swift

      public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>)

  #### Parameters

  `keyPath` | the keyPath for the attribute