# Google BigQuery v2 API - Class BigQueryInsertRow (3.12.0)

3.12.0 (latest) 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.4.0 2.3.0 2.2.0

    public sealed class BigQueryInsertRow : IEnumerable

Reference documentation and code samples for the Google BigQuery v2 API class BigQueryInsertRow.

A row used for streaming data insertion.

## Inheritance

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

## Implements

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [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.BigQuery.V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2)

## Assembly

Google.Cloud.BigQuery.V2.dll

## Remarks


This is effectively a dictionary where each key is the field name (a string)
and the value is the corresponding value for that field.
Supported value types:

- `System.Boolean`
- `System.Int16`
- `System.UInt16`
- `System.Int32`
- `System.UInt32`
- `System.Int64`
- `System.Float`
- `System.Double`
- `System.String`
- `System.DateTime`
- `System.DateTimeOffset`
- `System.TimeSpan`
- `Google.Cloud.BigQuery.V2.BigQueryNumeric`
- `Google.Cloud.BigQuery.V2.BigQueryGeography`
- A `Google.Cloud.BigQuery.V2.InsertRow` (for record/struct fields)
- Any `IReadOnlyList<T>` of one of the above types (for repeated fields). This includes arrays and `List<T>` values.


Note that all integer types are stored as `System.Int64`, and all floating point
types are stored as `System.Double.`

`DateTimeOffset` values are converted to UTC and treated as timestamp. The handling
of `DateTime` values depends on the `Kind`: values with a `Kind` of `Local` are rejected;
values with a `Kind` of `UTC` are treated as timestamps; values with a `Kind` of `Unspecified`
are treated as civil datetime values. All values are stored with a precision of a microsecond.


`TimeSpan` values must be non-negative and less than 24 hours, used to represent a time-of-day.


Although date values are retrieved as `System.DateTime`, they must be inserted as string values, in the format
"yyyy-MM-dd".


[BigQueryInsertRow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryInsertRow) is used for record/struct fields for convenience, but only the [InsertId](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryInsertRow#Google_Cloud_BigQuery_V2_BigQueryInsertRow_InsertId)
of the top-level row is relevant.


Null elements within repeated fields are prohibited. This is validated client-side when the row is inserted; validating
when a value is added to the row would be ineffective as the values could change before insertion.

## Constructors

### BigQueryInsertRow()

    public BigQueryInsertRow()

Constructs an empty row with no insert ID.

### BigQueryInsertRow(string)

    public BigQueryInsertRow(string insertId)

Constructs an empty row with the specified insert ID.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `insertId` | `https://learn.microsoft.com/dotnet/api/system.string` Insert ID used for deduplication. May be null. |

## Properties

### InsertId

    public string InsertId { get; set; }

To help ensure data consistency, you can supply an [InsertId](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryInsertRow#Google_Cloud_BigQuery_V2_BigQueryInsertRow_InsertId) for each inserted row.
BigQuery remembers this ID for at least one minute. If you try to stream the same set of rows within
that time period and the insertId property is set, BigQuery uses the property to de-duplicate
your data on a best effort basis. By default if no ID is specified, one will be generated to allow
de-duplicating efforts if insert operations need to be retried.
You can allow empty [InsertId](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryInsertRow#Google_Cloud_BigQuery_V2_BigQueryInsertRow_InsertId) by setting [AllowEmptyInsertIds](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.InsertOptions#Google_Cloud_BigQuery_V2_InsertOptions_AllowEmptyInsertIds) to true.
This will allow for faster row inserts at the expense of possible record duplication if the operation needs to be retried.
See <https://cloud.google.com/bigquery/quotas#streaming_inserts> for more information.

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

### this\[string\]

    public object this[string name] { get; set; }

Accesses a field in the row by name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field to access. Must be a valid BigQuery field name. |

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` | The value associated with `name`. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.keynotfoundexception` | The row does not have a key with the given name. |

## Methods

### Add(IDictionary\<string, object\>)

    public void Add(IDictionary<string, object> fields)

Adds all the values in the specified dictionary to the row.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `fields` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.idictionary-2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.object` The fields to add to the row. Must not be null. |

**Remarks** This being named `Add` rather than `AddRange` allows
it to be specified in a collection initializer, which can be useful
to provide a set of common fields and then some extra values.

### Add(string, object)

    public void Add(string key, object value)

Adds a single field value to the row.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field. Must be a valid BigQuery field name. |
| `value` | `https://learn.microsoft.com/dotnet/api/system.object` The value for the field, which must be `null` or one of the supported types. |