---
title: EntityQueryComparator
framework: appintents
role: symbol
role_heading: Class
path: appintents/entityquerycomparator
---

# EntityQueryComparator

The base class for all concrete entity query comparators.

## Declaration

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

## Overview

Overview An entity query comparator specifies a particular query comparison that can be made against a 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 on a fictional IntentPersonEntity that allows finding entities by strict equality or prefix on the entity firstName property by defining its supported EntityQueryComparators: 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 Resolvers to fine-tune how the system will transform a user’s supplied value into into the target Value type.

## Relationships

### Inherited By

- [ContainsComparator](appintents/containscomparator.md)
- [EqualToComparator](appintents/equaltocomparator.md)
- [GreaterThanComparator](appintents/greaterthancomparator.md)
- [GreaterThanOrEqualToComparator](appintents/greaterthanorequaltocomparator.md)
- [HasPrefixComparator](appintents/hasprefixcomparator.md)
- [HasSuffixComparator](appintents/hassuffixcomparator.md)
- [IsBetweenComparator](appintents/isbetweencomparator.md)
- [LessThanComparator](appintents/lessthancomparator.md)
- [LessThanOrEqualToComparator](appintents/lessthanorequaltocomparator.md)
- [NotEqualToComparator](appintents/notequaltocomparator.md)

## See Also

### Building query comparators

- [buildBlock(_:)](appintents/entityquerycomparatorsbuilder/buildblock(_:).md)
- [AnyEntityQueryComparator](appintents/anyentityquerycomparator.md)
- [buildExpression(_:)](appintents/entityquerycomparatorsbuilder/buildexpression(_:)-4g6f9.md)
- [buildExpression(_:)](appintents/entityquerycomparatorsbuilder/buildexpression(_:)-5tlbq.md)
- [buildExpression(_:)](appintents/entityquerycomparatorsbuilder/buildexpression(_:)-6v6cj.md)
- [buildExpression(_:)](appintents/entityquerycomparatorsbuilder/buildexpression(_:)-8jx4k.md)
