Esempio n. 1
0
        private static string _Get_val_from_usqlarray <T>(USQLINTERFACES.IRow row, USQLINTERFACES.IColumn col, string val)
        {
            var arr = row.Get <USQLTYPES.SqlArray <T> >(col.Name);

            if (arr != null)
            {
                var sb = new System.Text.StringBuilder();
                sb.Append("SqlArray<");
                sb.Append(get_usql_type_name(typeof(T)));
                sb.Append(">{ ");

                for (int j = 0; j < arr.Count; j++)
                {
                    if (j > 0)
                    {
                        sb.Append(", ");
                    }

                    sb.Append("\"");
                    sb.Append(arr[j].ToString());
                    sb.Append("\"");
                }

                sb.Append(" }");
                val = sb.ToString();
            }
            else
            {
                val = "NULL";
            }
            return(val);
        }
Esempio n. 2
0
        private static string _Get_val_from_usqlmap <K, V>(USQLINTERFACES.IRow row, USQLINTERFACES.IColumn col, string val)
        {
            var map = row.Get <USQLTYPES.SqlMap <K, V> >(col.Name);

            if (map != null)
            {
                var sb = new System.Text.StringBuilder();
                sb.Append("SqlMap<");
                sb.Append(get_usql_type_name(typeof(K)));
                sb.Append(", ");
                sb.Append(get_usql_type_name(typeof(V)));
                sb.Append(">{ ");

                int kn = 0;
                foreach (var key in map.Keys)
                {
                    if (kn > 0)
                    {
                        sb.Append("; ");
                    }

                    V      xval    = map[key];
                    string val_str = "NULL";
                    if (xval != null)
                    {
                        val_str = xval.ToString();
                    }

                    var key_str = key.ToString();
                    sb.AppendFormat("{0}={1}", key_str, val_str);

                    kn++;
                }

                sb.Append(" }");
                val = sb.ToString();
            }
            else
            {
                val = "NULL";
            }
            return(val);
        }
Esempio n. 3
0
        public static string GetValueFromUsqlMap <K, V>(Microsoft.Analytics.Interfaces.IRow row, Microsoft.Analytics.Interfaces.IColumn col, TypeDisplayNameOptions opts)
        {
            string val = null;

            var map = row.Get <Microsoft.Analytics.Types.Sql.SqlMap <K, V> >(col.Name);

            if (map != null)
            {
                var sb = new System.Text.StringBuilder();
                sb.Append("SqlMap");
                if (opts.ShowGenericParameters)
                {
                    sb.Append(_LESSTHAN);
                    sb.Append(UdoUtils.GetUsqlTypeDisplayName(typeof(K)));
                    sb.Append(_COMMA);
                    sb.Append(_SPACE);
                    sb.Append(UdoUtils.GetUsqlTypeDisplayName(typeof(V)));
                    sb.Append(_GREATERTHAN);
                }
                sb.Append(_LEFTCURLYBRACE);
                sb.Append(_SPACE);

                int kn = 0;
                foreach (var key in map.Keys)
                {
                    if (kn > 0)
                    {
                        sb.Append(_SEMICOLON);
                        sb.Append(_SPACE);
                    }

                    V      xval    = map[key];
                    string val_str = "NULL";
                    if (xval != null)
                    {
                        val_str = xval.ToString();
                    }

                    var key_str = key.ToString();
                    sb.AppendFormat("{0}={1}", key_str, val_str);

                    kn++;
                }
                sb.Append(_SPACE);
                sb.Append(_RIGHTCURLYBRACE);
                val = sb.ToString();
            }
            else
            {
                val = "NULL";
            }
            return(val);
        }
Esempio n. 4
0
        public static string GetValueDisplayString(Microsoft.Analytics.Interfaces.IRow row, Type type, string val, Microsoft.Analytics.Interfaces.IColumn col, TypeDisplayNameOptions opts)
        {
            if (type == typeof(string))
            {
                val = row.Get <string>(col.Name) ?? _NULL;
            }
            else if (type == typeof(bool))
            {
                val = row.Get <bool>(col.Name).ToString();
            }
            else if (type == typeof(char))
            {
                val = row.Get <char>(col.Name).ToString();
            }
            else if (type == typeof(float))
            {
                val = row.Get <float>(col.Name).ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
            else if (type == typeof(double))
            {
                val = row.Get <double>(col.Name).ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
            else if (type == typeof(int))
            {
                val = row.Get <int>(col.Name).ToString();
            }
            else if (type == typeof(long))
            {
                val = row.Get <long>(col.Name).ToString();
            }
            else if (type == typeof(System.Guid))
            {
                val = row.Get <System.Guid>(col.Name).ToString();
            }
            else if (type == typeof(int?))
            {
                val = row.Get <int?>(col.Name).ToString();
            }
            else if (type == typeof(long?))
            {
                val = row.Get <long?>(col.Name).ToString();
            }
            else if (type == typeof(float?))
            {
                val = row.Get <float?>(col.Name).ToString();
            }
            else if (type == typeof(double?))
            {
                val = row.Get <double?>(col.Name).ToString();
            }
            else if (type.IsGenericType)
            {
                val = GetValueFromUsqlArray_(row, type, col, opts);

                if (val == null)
                {
                    val = GetValueFromUsqlMap_(row, type, col, opts);
                }

                if (val == null)
                {
                    val = UdoUtils.GetUsqlTypeDisplayName(type);
                }
            }
            else
            {
                val = UdoUtils.GetUsqlTypeDisplayName(type);
            }
            return(val);
        }
Esempio n. 5
0
        public static string GetValueFromUsqlArray <T>(Microsoft.Analytics.Interfaces.IRow row, Microsoft.Analytics.Interfaces.IColumn col, string val, TypeDisplayNameOptions opts)
        {
            var arr = row.Get <Microsoft.Analytics.Types.Sql.SqlArray <T> >(col.Name);

            if (arr != null)
            {
                var sb = new System.Text.StringBuilder();
                sb.Append("SqlArray");
                if (opts.ShowGenericParameters)
                {
                    sb.Append(_LESSTHAN);
                    sb.Append(UdoUtils.GetUsqlTypeDisplayName(typeof(T)));
                    sb.Append(_GREATERTHAN);
                }
                sb.Append(_LEFTCURLYBRACE);
                sb.Append(_SPACE);

                for (int j = 0; j < arr.Count; j++)
                {
                    if (j > 0)
                    {
                        sb.Append(_COMMA);
                        sb.Append(_SPACE);
                    }

                    sb.Append(_DOUBLEQUOTE);
                    sb.Append(arr[j].ToString());
                    sb.Append(_DOUBLEQUOTE);
                }

                sb.Append(_SPACE);
                sb.Append(_RIGHTCURLYBRACE);

                val = sb.ToString();
            }
            else
            {
                val = "NULL";
            }
            return(val);
        }