<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/EntityQueryComparator",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents21EntityQueryComparatorC"
  },
  "title" : "EntityQueryComparator"
}
-->

# EntityQueryComparator

The base class for all concrete entity query comparators.

```
class EntityQueryComparator<Property, PropertyType, InputType, ComparatorMappingType> where Property : EntityProperty<PropertyType>, PropertyType : _IntentValue, PropertyType : Sendable, InputType : _IntentValue
```

## Overview

An entity query comparator specifies a particular query comparison that can be made against a
[`EntityQueryProperty`](/documentation/AppIntents/EntityQueryProperty). For each query property comparator, `mappingTransform` maps the
user-supplied `Value` at runtime into a `ComparatorMappingType` type of your choice.

The following example illustrates the declaration of a [`EntityQueryProperty`](/documentation/AppIntents/EntityQueryProperty) on a fictional
`IntentPersonEntity` that allows finding entities by strict equality or prefix on the entity
`firstName` property by defining its supported `EntityQueryComparator`s:

```
Property(\.$firstName) {
   EqualToComparator { value in
        // This is called at runtime with `value` being the user-supplied value.
        // For example, value would be: "John" when the user says:
        // "Hey Siri, find persons named John", given the appropriate mapping
        // in the application's Siri metadata.

        // This closure returns an object of type `ComparatorMappingType`. In the context of
        // a `EntityQuery`, every `EntityQueryComparator` must return the same output type,
        // which is the Query's `ComparatorMappingType`.
        return "firstName must be equal to \{value}"
   }
   HasPrefixComparator { "firstName must start with \{$0}" }
}
```

## Resolvers

Additionally, you can supply a set of [`Resolver`](/documentation/AppIntents/Resolver)s to fine-tune how the system will transform
a user’s supplied value into into the target `Value` type.

## Relationships

### Inherited By

[`HasPrefixComparator`](/documentation/AppIntents/HasPrefixComparator)

[`GreaterThanComparator`](/documentation/AppIntents/GreaterThanComparator)

[`ContainsComparator`](/documentation/AppIntents/ContainsComparator)

[`NotEqualToComparator`](/documentation/AppIntents/NotEqualToComparator)

[`EqualToComparator`](/documentation/AppIntents/EqualToComparator)

[`HasSuffixComparator`](/documentation/AppIntents/HasSuffixComparator)

[`LessThanOrEqualToComparator`](/documentation/AppIntents/LessThanOrEqualToComparator)

[`LessThanComparator`](/documentation/AppIntents/LessThanComparator)

[`IsBetweenComparator`](/documentation/AppIntents/IsBetweenComparator)

[`GreaterThanOrEqualToComparator`](/documentation/AppIntents/GreaterThanOrEqualToComparator)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)