# Google BigQuery v2 API - Class TableSchemaBuilder (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 TableSchemaBuilder : IEnumerable

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

Class making it simple to create a [TableSchema](https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html).

## Inheritance

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

## 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 class only implements [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable) in order to allow it to be used in
collection initializers.

## Methods

### Add(TableFieldSchema)

    public void Add(TableFieldSchema field)

Adds the given field to the schema being built.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableFieldSchema.html` The field to add. Must not be null. |

### Add(string, TableSchema, BigQueryFieldMode, string)

    public void Add(string name, TableSchema nestedSchema, BigQueryFieldMode mode = BigQueryFieldMode.Nullable, string description = null)

Creates a nested field with the specified schema, and adds it to the schema being built.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field. Must be a valid field name. |
| `nestedSchema` | `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html` The schema for the nested field. Must not be null. |
| `mode` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode` The mode of the field. Must be a defined member within [BigQueryFieldMode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode). |
| `description` | `https://learn.microsoft.com/dotnet/api/system.string` The description of the field. May be null. |

### Add(string, BigQueryDbType, BigQueryFieldMode, string)

    public void Add(string name, BigQueryDbType type, BigQueryFieldMode mode = BigQueryFieldMode.Nullable, string description = null)

Creates a field with the specified details, and adds it to the schema being built.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field. Must be a valid field name. |
| `type` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryDbType` The type of the field. Must be a defined member within [BigQueryDbType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryDbType), other than `Struct` or `Array`. |
| `mode` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode` The mode of the field. Must be a defined member within [BigQueryFieldMode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode). |
| `description` | `https://learn.microsoft.com/dotnet/api/system.string` The description of the field. May be null. |

### Add(string, TableSchemaBuilder, BigQueryFieldMode, string)

    public void Add(string name, TableSchemaBuilder nestedSchema, BigQueryFieldMode mode = BigQueryFieldMode.Nullable, string description = null)

Creates a nested field with the specified schema, and adds it to the schema being built.
This method simply delegates to [Add(string, TableSchema, BigQueryFieldMode, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder#Google_Cloud_BigQuery_V2_TableSchemaBuilder_Add_System_String_Google_Apis_Bigquery_v2_Data_TableSchema_Google_Cloud_BigQuery_V2_BigQueryFieldMode_System_String_) after calling [Build()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder#Google_Cloud_BigQuery_V2_TableSchemaBuilder_Build)
on `nestedSchema`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field. Must be a valid field name. |
| `nestedSchema` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder` The schema for the nested field, in the form of a [TableSchemaBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder). Must not be null. |
| `mode` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode` The mode of the field. Must be a defined member within [BigQueryFieldMode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryFieldMode). |
| `description` | `https://learn.microsoft.com/dotnet/api/system.string` The description of the field. May be null. |

### Build()

    public TableSchema Build()

Constructs a [TableSchema](https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html) from this builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html` | A [TableSchema](https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html) from the fields added to this builder. |

### ModifyField(string, Action\<TableFieldSchema\>)

    public TableSchemaBuilder ModifyField(string fieldName, Action<TableFieldSchema> fieldModifier)

Modifies the field with `fieldName` by running the given action.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `fieldName` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the field to be modified. Must not be null. |
| `fieldModifier` | `https://learn.microsoft.com/dotnet/api/system.action-1https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableFieldSchema.html` An action to be performed on the given field. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder` | This [TableSchemaBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.TableSchemaBuilder) after having applied the modification. For the purposes of method chaining. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.argumentexception` | `fieldName` is not present within the schema being built. |