在c#中使用bigquery API时获取sql查询的列名



如何打印所有列名?Console.WriteLine(row.RawRow.ETag);不起作用,它打印空白行

这是我迄今为止的代码

static void Main(string[] args)
{
List<string> rows = new List<string>();
string projectId = "project-id 123";
var client = BigQueryClient.Create(projectId);
string sql = @"SELECT * FROM table";
var res = client.ExecuteQuery(sql, parameters: null);
foreach (var row in res)
Console.WriteLine(row["id"])
//rows.Add(row["id"])
}

其中一个例子的答案是

此处

public List<T> Execute<T>(string sql)
{
var client = BigQueryClient.Create(projectId);
List<T> result = new List<T>();
try
{
string query = sql;
BigQueryResults results = client.ExecuteQuery(query, parameters: null);
List<string> fields = new List<string>();
foreach (var col in results.Schema.Fields)
{
fields.Add(col.Name);
}

最新更新