// [END build_service]

        // [START run_query]
        /// <summary>
        /// Executes the given query synchronously.
        /// </summary>
        /// <param name="querySql">the query to execute.</param>
        /// <param name="bigquery">the BigquerService object.</param>
        /// <param name="projectId">the id of the project under which to run the query.</param>
        /// <returns>a list of the results of the query.</returns>
        public static async Task<IList<TableRow>> ExecuteQueryAsync(
            string querySql, BigqueryService bigquery, string projectId)
        {
            var request = new Google.Apis.Bigquery.v2.JobsResource.QueryRequest(
                bigquery, new Google.Apis.Bigquery.v2.Data.QueryRequest()
                {
                    Query = querySql,
                }, projectId);
            var query = await request.ExecuteAsync();
            GetQueryResultsResponse queryResult = await
                bigquery.Jobs.GetQueryResults(projectId, query.JobReference.JobId).ExecuteAsync();
            return queryResult.Rows;
        }