4.6.0 (latest) 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.5.0 2.4.0 2.3.1

    public sealed class AggregateField : IEquatable<AggregateField>

Reference documentation and code samples for the Firestore API class AggregateField.

Represents a single aggregation within an [AggregateQuery](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateQuery).

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> AggregateField

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField)

## Inherited Members

[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Firestore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore)

## Assembly

Google.Cloud.Firestore.dll

## Properties

### Alias

    public string Alias { get; }

The alias for this aggregate field. This is either specified explicitly on construction,
or may be defaulted.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

## Methods

### Average(string, string)

    public static AggregateField Average(string field, string alias = null)

It uses the server side aggregation Google.Cloud.Firestore.V1.StructuredAggregationQuery.Types.Aggregation.Avg representing a server-side average aggregation function.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://learn.microsoft.com/dotnet/api/system.string` The field on which the average aggregation is performed. Must not be null. |
| `alias` | `https://learn.microsoft.com/dotnet/api/system.string` Optional alias to identify the result of the aggregation in [AggregateQuerySnapshot](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateQuerySnapshot). If this is null, an alias of the form "Avg_{field}" is used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField` | Returns a new instance of [AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField). |

### Count()

    public static AggregateField Count()

Creates an [AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField) representing a server-side count aggregation function.
The `COUNT(*)` aggregation function operates on the entire document so it does not require a field reference.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField` | Returns a new instance of [AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField). |

### GetHashCode()

    public override int GetHashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

**Overrides** [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)

### Sum(string, string)

    public static AggregateField Sum(string field, string alias = null)

Creates an [AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField) representing a server-side sum aggregation function.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://learn.microsoft.com/dotnet/api/system.string` The field on which the sum aggregation is performed. Must not be null. |
| `alias` | `https://learn.microsoft.com/dotnet/api/system.string` Optional alias to identify the result of the aggregation in [AggregateQuerySnapshot](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateQuerySnapshot). If this is null, an alias of the form "Sum_{field}" is used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField` | Returns a new instance of [AggregateField](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.AggregateField). |