Esempio n. 1
0
        static string ConvertToString(BigQueryParameter parameter)
        {
            if (parameter?.Value == null)
            {
                return(null);
            }

            string format = "{0}";

            switch (parameter.BigQueryDbType)
            {
            case BigQueryDbType.DateTime:
                format = "{0:yyyy-MM-dd HH:mm:ss.ffffff}";
                break;

            case BigQueryDbType.Date:
                format = "{0:yyyy-MM-dd}";
                break;

            case BigQueryDbType.Time:
                format = "{0:HH:mm:ss.ffffff}";
                break;

            case BigQueryDbType.Timestamp:
                format = "{0:u}";
                break;
            }

            return(parameter.Value.ToInvariantString(format));
        }
Esempio n. 2
0
        static string ConvertToStringForLegacySql(BigQueryParameter parameter)
        {
            if (parameter?.Value == null)
            {
                return(null);
            }

            if (parameter.BigQueryDbType == BigQueryDbType.String)
            {
                var invariantString = parameter.Value.ToInvariantString();
                var trimmedString   = invariantString.Substring(0, parameter.Size);
                var escapedString   = EscapeString(trimmedString);
                return($"'{escapedString}'");
            }

            string format = "{0}";

            switch (parameter.BigQueryDbType)
            {
            case BigQueryDbType.DateTime:
                format = "cast('{0}' as DATETIME)";
                break;

            case BigQueryDbType.Date:
                format = "cast('{0}' as DATE)";
                break;

            case BigQueryDbType.Time:
                format = "cast('{0}' as TIME)";
                break;

            case BigQueryDbType.Timestamp:
                format = "cast('{0}' as TIMESTAMP)";
                break;
            }

            return(ConvertToString(parameter).ToInvariantString(format));
        }
        /// <summary>
        /// returns the index of the specified parameter.
        /// </summary>
        /// <param name="parameterName">The name of a BigQueryParameter.</param>
        /// <returns>the index of the specified BigQueryParameter.</returns>
        public override int IndexOf(string parameterName)
        {
            BigQueryParameter value = innerList.FirstOrDefault(p => p.ParameterName == parameterName);

            return(IndexOf(value));
        }