无法使用 C# 在 BigQuery 中创建新的 TableSchema

Unable to create new TableSchema in BigQuery with C#

我正在尝试创建 Google BigQuery Table 模式 显式地,TableSchema.Fields.Add() 方法抛出对象引用异常。

        TableSchema Schema = response.Schema;

        TableFieldSchema sc1 = new TableFieldSchema();
        sc1.Name = "CustomerID";
        sc1.Type = "STRING";
        sc1.Mode = "NULLABLE";

        Schema.Fields.Add(sc1); -- Throws Error.

我可以使用以下代码在 .NET 客户端库中创建新的 TableSchema。

TableSchema Schema = new TableSchema();
TableFieldSchema F1 = new TableFieldSchema();
F1.Name = "COLUMN NAME";
F1.Type = "STRING";
F1.Mode = "REQUIRED";

TableFieldSchema F2 = new TableFieldSchema();
F1.Name = "COLUMN NAME";
F1.Type = "INTEGER";
F1.Mode = "NULLABLE";

//Add N number of fields as per your needs

System.Collections.Generic.IList<TableFieldSchema> FS = new System.Collections.Generic.List<TableFieldSchema>();
FS.Add(F1);
FS.Add(F2);

Schema.Fields = FS;