# Expression Structure Reference

# Expression

    public struct Expression<T, V> : CustomStringConvertible, DynamicKeyPath where T : WhereExpressionTrait

Type-safe keyPath chain usable in query/fetch expressions.

    let expression: Where<Pet>.Expression = (\.master ~ \.name)
    let owner = CoreStore.fetchOne(
       From<Pet>().where(expression == "John")
    )

- `Trait`

  Currently supports `SingleTarget` and `CollectionTarget`.

  #### Declaration

  Swift

      public typealias Trait = T

### AnyDynamicKeyPath

- `cs_keyPathString`

  #### Declaration

  Swift

      public let cs_keyPathString: String

### DynamicKeyPath

- `ObjectType`

  #### Declaration

  Swift

      public typealias ObjectType = D

- `ValueType`

  #### Declaration

  Swift

      public typealias ValueType = V

### CustomStringConvertible

- `description`

  #### Declaration

  Swift

      public var description: String { get }

### Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCCollectionKeyPathValue

- `count()`

  Creates a `Where.Expression` clause for COUNT

      let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))

  #### Declaration

  Swift

      public func count() -> Where<D>.Expression<T, Int>

### Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCKeyPathValue

- `any()`

  Creates a `Where.Expression` clause for ANY

      let dogsWithBadNamingSense = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))

  #### Declaration

  Swift

      public func any() -> Where<D>.Expression<T, V>

- `all()`

  Creates a `Where.Expression` clause for ALL

      let allPlaymatePuppies = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))

  #### Declaration

  Swift

      public func all() -> Where<D>.Expression<T, V>

- `none()`

  Creates a `Where.Expression` clause for NONE

      let dogs = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))

  #### Declaration

  Swift

      public func none() -> Where<D>.Expression<T, V>

### Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTarget

- `count()`

  Creates a `Where.Expression` clause for COUNT

      let dogsWithPlaymates = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))

  #### Declaration

  Swift

      public func count() -> Where<D>.Expression<T, Int>

- `any()`

  Creates a `Where.Expression` clause for ANY

      let dogsWithBadNamingSense = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))

  #### Declaration

  Swift

      public func any() -> Where<D>.Expression<T, V>

- `all()`

  Creates a `Where.Expression` clause for ALL

      let allPlaymatePuppies = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))

  #### Declaration

  Swift

      public func all() -> Where<D>.Expression<T, V>

- `none()`

  Creates a `Where.Expression` clause for NONE

      let dogs = CoreStore.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))

  #### Declaration

  Swift

      public func none() -> Where<D>.Expression<T, V>