C# 在c中使用bigquery API时获取sql查询的列名
如何打印所有列名? Console.WriteLinerow.RawRow.ETag;不起作用它打印空白行 这是到目前为止我的代码C# 在c中使用bigquery API时获取sql查询的列名,c#,google-bigquery,C#,Google Bigquery,如何打印所有列名? Console.WriteLinerow.RawRow.ETag;不起作用它打印空白行 这是到目前为止我的代码 static void Main(string[] args) { List<string> rows = new List<string>(); string projectId = "project-id 123"; var client = BigQueryCl
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"])
}
其中一个例子有你的答案
你能检查foreach循环中的调试器吗?我找到了解决方案,谢谢
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);
}