示例#1
0
        /// <summary>
        /// Creates new Snowflake client.
        /// </summary>
        /// <param name="settings">Client settings to initialize new session.</param>
        public SnowflakeClient(SnowflakeClientSettings settings)
        {
            ValidateClientSettings(settings);

            _clientSettings = settings;
            _restClient     = new RestClient();
            _requestBuilder = new RequestBuilder(settings.UrlInfo);
            SnowflakeDataMapper.SetJsonMapperOptions(settings.JsonMapperOptions);
        }
示例#2
0
        /// <summary>
        /// Executes a query, returning the data typed as <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">The type of results to return.</typeparam>
        /// <param name="sql">The SQL to execute.</param>
        /// <param name="sqlParams">The parameters to use for this command.</param>
        /// <returns>A sequence of data of the supplied type: one instance per row.</returns>
        public async Task <IEnumerable <T> > QueryAsync <T>(string sql, object sqlParams = null)
        {
            var response = await QueryInternalAsync(sql, sqlParams).ConfigureAwait(false);

            if (response.Data.Chunks != null && response.Data.Chunks.Count > 0)
            {
                throw new SnowflakeException("Downloading data from chunks is not implemented yet.");
            }

            var result = SnowflakeDataMapper.MapTo <T>(response.Data.RowType, response.Data.RowSet);

            return(result);
        }