private void DetermineSqlDbType()
        {
            // Determine the SqlDbType
            SqlDbType type;

            if (Enum.TryParse(DataTypeName, true, out type))
            {
                SqlDbType = type;
            }
            else
            {
                switch (DataTypeName)
                {
                case "numeric":
                    SqlDbType = SqlDbType.Decimal;
                    break;

                case "sql_variant":
                    SqlDbType = SqlDbType.Variant;
                    break;

                case "timestamp":
                    SqlDbType = SqlDbType.VarBinary;
                    break;

                case "sysname":
                    SqlDbType = SqlDbType.NVarChar;
                    break;

                default:
                    SqlDbType = DataTypeName.EndsWith(".sys.hierarchyid") ? SqlDbType.NVarChar : SqlDbType.Udt;
                    break;
                }
            }
        }
Example #2
0
        public DataType(DataTypeName typeName,
                        bool unsigned,
                        bool zerofill,
                        bool binary,
                        IExpression length,
                        IExpression decimals,
                        Identifier charSet,
                        Identifier collation,
                        IList<IExpression> collectionVals)
        {
            // BIT[(length)]
            // | TINYINT[(length)] [UNSIGNED] [ZEROFILL]
            // | SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
            // | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
            // | INT[(length)] [UNSIGNED] [ZEROFILL]
            // | INTEGER[(length)] [UNSIGNED] [ZEROFILL]
            // | BIGINT[(length)] [UNSIGNED] [ZEROFILL]
            // | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL]
            // | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL] 同上
            // | DATE
            // | TIME
            // | TIMESTAMP
            // | DATETIME
            // | YEAR
            // | CHAR[(length)][CHARACTER SET charset_name] [COLLATE collation_name]
            // | VARCHAR(length)[CHARACTER SET charset_name] [COLLATE collation_name]
            // | BINARY[(length)]
            // | VARBINARY(length)
            // | TINYBLOB
            // | BLOB
            // | MEDIUMBLOB
            // | LONGBLOB
            // | TINYTEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | TEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | MEDIUMTEXT [BINARY][CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | LONGTEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | ENUM(value1,value2,value3,...)[CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | SET(value1,value2,value3,...)[CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | spatial_type 不支�?
            if (typeName == DataTypeName.None)
            {
                throw new ArgumentException("typeName is null");
            }

            TypeName = typeName;
            IsUnsigned = unsigned;
            IsZerofill = zerofill;
            IsBinary = binary;
            Length = length;
            Decimals = decimals;
            CharSet = charSet;
            Collation = collation;
            CollectionVals = collectionVals;
        }
        public static DataBaseDAO CreateDataBaseDAO(DataTypeName dataTypeName)
        {
            DataBaseDAO dataBaseDAO = null;

            switch (dataTypeName)
            {
            case DataTypeName.ShouldPadDataTable:
                dataBaseDAO = new ShouldPadDAO();
                break;

            case DataTypeName.InOutDataTable:
                dataBaseDAO = new InOutDataDAO();
                break;

            case DataTypeName.BaseDataTable:
                dataBaseDAO = new MachineBaseDataDAO();
                break;

            case DataTypeName.FlowDataTable:
                dataBaseDAO = new FlowDataDAO();
                break;

            default:
                break;
            }
            return(dataBaseDAO);
        }
Example #4
0
        public DataType(DataTypeName typeName,
                        bool unsigned,
                        bool zerofill,
                        bool binary,
                        IExpression length,
                        IExpression decimals,
                        Identifier charSet,
                        Identifier collation,
                        IList <IExpression> collectionVals)
        {
            // BIT[(length)]
            // | TINYINT[(length)] [UNSIGNED] [ZEROFILL]
            // | SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
            // | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
            // | INT[(length)] [UNSIGNED] [ZEROFILL]
            // | INTEGER[(length)] [UNSIGNED] [ZEROFILL]
            // | BIGINT[(length)] [UNSIGNED] [ZEROFILL]
            // | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
            // | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL]
            // | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL] 同上
            // | DATE
            // | TIME
            // | TIMESTAMP
            // | DATETIME
            // | YEAR
            // | CHAR[(length)][CHARACTER SET charset_name] [COLLATE collation_name]
            // | VARCHAR(length)[CHARACTER SET charset_name] [COLLATE collation_name]
            // | BINARY[(length)]
            // | VARBINARY(length)
            // | TINYBLOB
            // | BLOB
            // | MEDIUMBLOB
            // | LONGBLOB
            // | TINYTEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | TEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | MEDIUMTEXT [BINARY][CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | LONGTEXT [BINARY][CHARACTER SET charset_name] [COLLATE collation_name]
            // | ENUM(value1,value2,value3,...)[CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | SET(value1,value2,value3,...)[CHARACTER SET charset_name] [COLLATE
            // collation_name]
            // | spatial_type 不支�?
            if (typeName == DataTypeName.None)
            {
                throw new ArgumentException("typeName is null");
            }

            TypeName       = typeName;
            IsUnsigned     = unsigned;
            IsZerofill     = zerofill;
            IsBinary       = binary;
            Length         = length;
            Decimals       = decimals;
            CharSet        = charSet;
            Collation      = collation;
            CollectionVals = collectionVals;
        }
        //开机时候的数据初始化
        public void InitSystemData()
        {
            SystemTimeManager.SystemTimerEx.GetStartTime();

            //读入机器参数XML
            MachineBaseDataDAO baseDataDAO = new MachineBaseDataDAO();

            baseDataDAO.LoadAllData();


            //读入花形参数XML
            ShouldPadDAO mouldDataDAO = new ShouldPadDAO();

            mouldDataDAO.FileIndex = baseDataDAO.GetSDataBaseValue(MachineBaseDataEnum.ID);
            mouldDataDAO.LoadAllData();

            DataTypeName[] dataTableNames = new DataTypeName[] { DataTypeName.InOutDataTable };
            DataBaseDAO    dataBaseDAO    = null;

            for (int i = 0; i < dataTableNames.Length; i++)
            {
                dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(dataTableNames[i]);
                dataBaseDAO.LoadAllData();
            }
            FlowDataDAO setDataDAO = new FlowDataDAO();

            setDataDAO.LoadAllData();
            serialDataManager = new SerialDataManager();
            serialDataManager.OpenSerialPort();
        }
Example #6
0
        /// <summary>
        /// 得到数据库类型名
        /// </summary>
        /// <param name="dtn">类型名</param>
        /// <returns></returns>
        public static DataTable GetDbData(DataTypeName dtn)
        {
            DataTable dt = null;

            switch (dtn)
            {
            case DataTypeName.表:
                dt = oleDb.GetDataTable("select tabschema,tabname from syscat.tables where tabschema in('DB2INST1','DB2INST2','DB2INST3') and type='T' order by tabname ");
                break;

            case DataTypeName.触发器:
                dt = oleDb.GetDataTable("select trigname from syscat.triggers");
                break;

            case DataTypeName.存储过程:
                dt = oleDb.GetDataTable("select procschema,procname from syscat.procedures where procschema in('DB2INST1','DB2INST2','DB2INST3') order by procname");
                break;

            case DataTypeName.函数:
                dt = oleDb.GetDataTable("select funcschema,funcname from syscat.functions where funcschema in('DB2INST1','DB2INST2','DB2INST3') order by funcname");
                break;

            case DataTypeName.视图:
                dt = oleDb.GetDataTable("select viewschema,viewname from syscat.views where viewschema in('DB2INST1','DB2INST2','DB2INST3') order by viewname");
                break;

            case DataTypeName.索引:
                dt = oleDb.GetDataTable("select indschema,indname from syscat.indexes where indschema in('DB2INST1','DB2INST2','DB2INST3') order by indname");
                break;
            }
            return(dt);
        }
        public static DataInfoSet CreateDataInfo(DataTypeName dataTypeName)
        {
            DataInfoSet dataInfoSet = null;

            switch (dataTypeName)
            {
            case DataTypeName.BaseDataTable:
                dataInfoSet = new MachineBaseDataInfoSet();
                break;

            case DataTypeName.CascadeDataTable:
                break;

            case DataTypeName.ShouldPadDataTable:
                dataInfoSet = new ShouldPadDataInfoSet();
                break;

            case DataTypeName.InOutDataTable:
                break;

            default:
                break;
            }
            return(dataInfoSet);
        }
Example #8
0
        public Type getType()
        {
            Type type = typeof(string);

            if (DataTypeName.Equals("decimal"))
            {
                type = typeof(double);
            }
            else if (DataTypeName.Equals("nvarchar"))
            {
                type = typeof(string);
            }
            else if (DataTypeName.Equals("bit"))
            {
                type = typeof(bool);
            }
            else if (DataTypeName.Equals("date"))
            {
                type = typeof(DateTime);
            }
            else if (DataTypeName.Equals("datetime"))
            {
                type = typeof(DateTime);
            }
            else if (DataTypeName.Equals("int"))
            {
                type = typeof(int);
            }
            return(type);
        }
Example #9
0
        public override int GetHashCode()
        {
            int result = ProviderType != null?ProviderType.GetHashCode() : 0;

            result = 29 * result + (DataTypeName != null ? DataTypeName.GetHashCode() : 0);
            result = 29 * result + NumericPrecision.GetHashCode();
            result = 29 * result + NumericScale.GetHashCode();
            result = 29 * result + ColumnSize.GetHashCode();
            result = 29 * result + IsLong.GetHashCode();
            return(result);
        }
Example #10
0
 void CalcHashCode()
 {
     unchecked
     {
         _hashCode = 639348056;
         _hashCode = _hashCode * -1521134295 + (ToType == null ? 0 : ToType.GetHashCode());
         _hashCode = _hashCode * -1521134295 + (FieldType == null ? 0 : FieldType.GetHashCode());
         _hashCode = _hashCode * -1521134295 + (ProviderFieldType == null ? 0 : ProviderFieldType.GetHashCode());
         _hashCode = _hashCode * -1521134295 + (DataTypeName == null ? 0 : DataTypeName.GetHashCode());
         _hashCode = _hashCode * -1521134295 + (DataReaderType == null ? 0 : DataReaderType.GetHashCode());
     }
 }
Example #11
0
        public string CreateValueString(object value)
        {
            if (value == DBNull.Value || value.ToString().Trim().ToUpper() == "NULL")
            {
                return("NULL");
            }

            switch (DataTypeName.ToLower())
            {
            case "uniqueidentifier":
            case "varchar":
            case "char":
            case "text":
                return($"'{value.ToString().Replace("'", "''")}'");

            case "nvarchar":
            case "nchar":
            case "ntext":
                return($"N'{value.ToString().Replace("'", "''")}'");

            case "money":
            case "smallmoney":
                return(value.ToString().Replace(',', '.'));

            case "float":
            case "real":
                var strValueF = FormatDecimal(value);
                return($"CAST({strValueF} AS Float({NumericPrecision})");

            case "numeric":
            case "decimal":
                var strValueD = FormatDecimal(value);
                return($"CAST({strValueD} AS Decimal({NumericPrecision}, {NumericScale}))");

            case "bit":
                var boolValue = Convert.ToBoolean(value);
                return(boolValue ? "1" : "0");

            case "datetime":
                DateTime datValue;
                if (!DateTime.TryParse(value.ToString(), out datValue))
                {
                    // Excel can internally store DateTime as double
                    var decValue = GetDouble(value);
                    datValue = DateTime.FromOADate(decValue);
                }
                return($"'{datValue.ToString("yyyy-MM-dd HH:mm:ss")}'");

            default:
                return(value.ToString());
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ColumnOrdinal;
         hashCode = (hashCode * 397) ^ (DataTypeName != null ? DataTypeName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ PrimaryKey.GetHashCode();
         hashCode = (hashCode * 397) ^ Generated.GetHashCode();
         hashCode = (hashCode * 397) ^ CaseSensitive.GetHashCode();
         return(hashCode);
     }
 }
 public DataButtonInfo()
 {
     freshEnable     = true;
     cascadeDataEnum = CascadeDataEnum.Null;
     mouldDataEnum   = ShouldPadDataEnum.Null;
     inOutDataEnum   = InOutDataEnum.Null;
     hasClick        = false;
     dataTypeName    = DataTypeName.Null;
     baseDataEnum    = MachineBaseDataEnum.Null;
     frameColor      = Color.Empty;
     dataInfo        = null;
     saveDataEnable  = true;
 }
            private SqlDbType GetSqlDbType()
            {
                switch (DataTypeName.ToLower())
                {
                case "bigint":
                    return(SqlDbType.BigInt);

                case "bit":
                    return(SqlDbType.Bit);

                case "char":
                    return(SqlDbType.Char);

                case "date":
                    return(SqlDbType.Date);

                case "datetime":
                    return(SqlDbType.DateTime);

                case "datetime2":
                    return(SqlDbType.DateTime2);

                case "float":
                    return(SqlDbType.Float);

                case "int":
                    return(SqlDbType.Int);

                case "nvarchar":
                    return(SqlDbType.NVarChar);

                case "real":
                    return(SqlDbType.Real);

                case "smallint":
                    return(SqlDbType.SmallInt);

                case "varbinary":
                    return(SqlDbType.VarBinary);

                case "varchar":
                    return(SqlDbType.VarChar);

                default:
                    return(SqlDbType.VarChar);
                }
            }
        private StringBuilder AppendDefinition(StringBuilder sql)
        {
            sql.Append(DataTypeName.ToUpper());
            if (DataType.IsRealNumberType() && NumericPrecision > 0)
            {
                sql.Append("(");
                sql.Append(NumericPrecision);
                if (NumericScale > 0)
                {
                    sql.Append(",");
                    sql.Append(NumericScale);
                }

                sql.Append(")");
            }
            else if (!DataType.IsNumericType() && ColumnSize > 0)
            {
                sql.Append("(");
                sql.Append(ColumnSize);
                sql.Append(")");
            }

            if (IsKey)
            {
                sql.Append(" PRIMARY KEY");
                if (IsAutoIncrement)
                {
                    sql.Append(" ").Append("AUTOINCREMENT");
                }
            }
            else
            {
                sql.Append(AllowDBNull ? " NULL" : " NOT NULL");

                if (IsUnique)
                {
                    sql.Append(" UNIQUE");
                }
            }

            if (DefaultValue != null)
            {
                sql.AppendFormat(" DEFAULT ({0})", DefaultValue);
            }

            return(sql);
        }
Example #16
0
        private string GetSqlDataType()
        {
            // If the column size = 2147483647, set it to a varchar(MAX), else just set it to the size
            var columnSizeString = ColumnSize.ToString() == 2147483647.ToString() ? "MAX" : ColumnSize.ToString();

            string sqlDataType = DataTypeName.ToUpper();

            if (DataTypeName.ToUpper().Contains("CHAR"))
            {
                sqlDataType = $"{DataTypeName.ToUpper()}({columnSizeString})";
            }
            else if (DataTypeName.ToUpper().Equals("DECIMAL") || DataTypeName.ToUpper().Equals("NUMERIC"))
            {
                sqlDataType = $"{DataTypeName.ToUpper()}({NumericPrecision},{NumericScale})";
            }
            return(sqlDataType);
        }
Example #17
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputDataType">The datatype to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(DataType inputDataType)
        {
            if (DataTypeName.GetString() != inputDataType.DataTypeName.GetString())
            {
                return(false);
            }
            if (LengthInBits.GetInt() != inputDataType.LengthInBits.GetInt())
            {
                return(false);
            }
            if (Description.GetString() != inputDataType.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
Example #18
0
        /// <summary>
        /// 获得发生错误的文件名,将该文件删除,并且将程序中的属于该文件的数据进行保存
        /// </summary>
        /// <param name="fileName"></param>
        public void RepairSaveMachineDatas(String fileName)
        {
            String[]       pathNames     = new string[] { "InOutData", "ShouldPadData", "BaseData" };
            DataTypeName[] dataTypeNames = new DataTypeName[] { DataTypeName.InOutDataTable
                                                                , DataTypeName.ShouldPadDataTable, DataTypeName.BaseDataTable };
            DataTypeName dataTypeName = DataTypeName.Null;

            fileName = DefaultPath.DefaultPathEx.DataBasePath + fileName;
            FileOperManager.DeleteFile(fileName);
            for (int i = 0; i < pathNames.Length; i++)
            {
                if (fileName.IndexOf(pathNames[i]) != -1)
                {
                    dataTypeName = dataTypeNames[i];
                    break;
                }
            }
            DataBaseDAO dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(dataTypeName);

            if (dataBaseDAO != null)
            {
                dataBaseDAO.SaveAllDataBase();
            }
        }
Example #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Ver != 0)
            {
                hash ^= Ver.GetHashCode();
            }
            if (DataTypeName.Length != 0)
            {
                hash ^= DataTypeName.GetHashCode();
            }
            if (DateTime.Length != 0)
            {
                hash ^= DateTime.GetHashCode();
            }
            if (samplingRate_ != null)
            {
                hash ^= SamplingRate.GetHashCode();
            }
            if (SequenceNumber.Length != 0)
            {
                hash ^= SequenceNumber.GetHashCode();
            }
            if (InstrumentationKey.Length != 0)
            {
                hash ^= InstrumentationKey.GetHashCode();
            }
            hash ^= Tags.GetHashCode();
            if (dataCase_ == DataOneofCase.Event)
            {
                hash ^= Event.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Message)
            {
                hash ^= Message.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Metric)
            {
                hash ^= Metric.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Exception)
            {
                hash ^= Exception.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Dependency)
            {
                hash ^= Dependency.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Availability)
            {
                hash ^= Availability.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.PageView)
            {
                hash ^= PageView.GetHashCode();
            }
            if (dataCase_ == DataOneofCase.Request)
            {
                hash ^= Request.GetHashCode();
            }
            hash ^= (int)dataCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #20
0
        /// <summary>
        /// Constructor for a DbColumnWrapper
        /// </summary>
        /// <remarks>Most of this logic is taken from SSMS ColumnInfo class</remarks>
        /// <param name="column">The column we're wrapping around</param>
        public DbColumnWrapper(DbColumn column)
        {
            // Set all the fields for the base
            AllowDBNull              = column.AllowDBNull;
            BaseCatalogName          = column.BaseCatalogName;
            BaseColumnName           = column.BaseColumnName;
            BaseSchemaName           = column.BaseSchemaName;
            BaseServerName           = column.BaseServerName;
            BaseTableName            = column.BaseTableName;
            ColumnOrdinal            = column.ColumnOrdinal;
            ColumnSize               = column.ColumnSize;
            IsAliased                = column.IsAliased;
            IsAutoIncrement          = column.IsAutoIncrement;
            IsExpression             = column.IsExpression;
            IsHidden                 = column.IsHidden;
            IsIdentity               = column.IsIdentity;
            IsKey                    = column.IsKey;
            IsLong                   = column.IsLong;
            IsReadOnly               = column.IsReadOnly;
            IsUnique                 = column.IsUnique;
            NumericPrecision         = column.NumericPrecision;
            NumericScale             = column.NumericScale;
            UdtAssemblyQualifiedName = column.UdtAssemblyQualifiedName;
            DataType                 = column.DataType;
            DataTypeName             = column.DataTypeName.ToLowerInvariant();

            // Determine the SqlDbType
            SqlDbType type;

            if (Enum.TryParse(DataTypeName, true, out type))
            {
                SqlDbType = type;
            }
            else
            {
                switch (DataTypeName)
                {
                case "numeric":
                    SqlDbType = SqlDbType.Decimal;
                    break;

                case "sql_variant":
                    SqlDbType = SqlDbType.Variant;
                    break;

                case "timestamp":
                    SqlDbType = SqlDbType.VarBinary;
                    break;

                case "sysname":
                    SqlDbType = SqlDbType.NVarChar;
                    break;

                default:
                    SqlDbType = DataTypeName.EndsWith(".sys.hierarchyid") ? SqlDbType.NVarChar : SqlDbType.Udt;
                    break;
                }
            }

            // We want the display name for the column to always exist
            ColumnName = string.IsNullOrEmpty(column.ColumnName)
                ? SR.QueryServiceColumnNull
                : column.ColumnName;

            switch (DataTypeName)
            {
            case "varchar":
            case "nvarchar":
                IsChars = true;

                Debug.Assert(ColumnSize.HasValue);
                if (ColumnSize.Value == int.MaxValue)
                {
                    //For Yukon, special case nvarchar(max) with column name == "Microsoft SQL Server 2005 XML Showplan" -
                    //assume it is an XML showplan.
                    //Please note this field must be in sync with a similar field defined in QESQLBatch.cs.
                    //This is not the best fix that we could do but we are trying to minimize code impact
                    //at this point. Post Yukon we should review this code again and avoid
                    //hard-coding special column name in multiple places.
                    const string yukonXmlShowPlanColumn = "Microsoft SQL Server 2005 XML Showplan";
                    if (column.ColumnName == yukonXmlShowPlanColumn)
                    {
                        // Indicate that this is xml to apply the right size limit
                        // Note we leave chars type as well to use the right retrieval mechanism.
                        IsXml = true;
                    }
                    IsLong = true;
                }
                break;

            case "text":
            case "ntext":
                IsChars = true;
                IsLong  = true;
                break;

            case "xml":
                IsXml  = true;
                IsLong = true;
                break;

            case "binary":
            case "image":
                IsBytes = true;
                IsLong  = true;
                break;

            case "varbinary":
            case "rowversion":
                IsBytes = true;

                Debug.Assert(ColumnSize.HasValue);
                if (ColumnSize.Value == int.MaxValue)
                {
                    IsLong = true;
                }
                break;

            case "sql_variant":
                IsSqlVariant = true;
                break;

            default:
                if (!AllServerDataTypes.Contains(DataTypeName))
                {
                    // treat all UDT's as long/bytes data types to prevent the CLR from attempting
                    // to load the UDT assembly into our process to call ToString() on the object.

                    IsUdt   = true;
                    IsBytes = true;
                    IsLong  = true;
                }
                break;
            }


            if (IsUdt)
            {
                // udtassemblyqualifiedname property is used to find if the datatype is of hierarchyid assembly type
                // Internally hiearchyid is sqlbinary so providerspecific type and type is changed to sqlbinarytype
                object       assemblyQualifiedName = column.UdtAssemblyQualifiedName;
                const string hierarchyId           = "MICROSOFT.SQLSERVER.TYPES.SQLHIERARCHYID";

                if (assemblyQualifiedName != null &&
                    assemblyQualifiedName.ToString().StartsWith(hierarchyId, StringComparison.OrdinalIgnoreCase))
                {
                    DataType = typeof(SqlBinary);
                }
                else
                {
                    DataType = typeof(byte[]);
                }
            }
            else
            {
                DataType = column.DataType;
            }
        }
            private object GetCastedValue(string fieldValue)
            {
                if (String.IsNullOrEmpty(fieldValue))
                {
                    if (IsNullable)
                    {
                        return(DBNull.Value);
                    }
                    if (DataTypeName == "bit")
                    {
                        return(false);
                    }
                    throw new NotSupportedException("This field cannot support a null value");
                }

                //Mappings of object types....
                //https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings
                //--bigint			==> int
                //--int				==> int
                //--smallint		==> int

                //--char			==> string
                //--nvarchar		==> string
                //--varchar			==> string

                //--bit				==> bool
                //--date			==> DateTime
                //--datetime		==> DateTime
                //--datetime2		==> DateTime
                //--float			==> Double
                //--real			==> single
                //--varbinary		==> byte[]
                switch (DataTypeName.ToLower())
                {
                case "bigint":
                case "int":
                case "smallint":
                    return(Int32.Parse(fieldValue));

                case "char":
                case "nvarchar":
                case "varchar":
                    return(fieldValue);

                case "date":
                case "datetime":
                case "datetime2":
                    return(DateTime.Parse(fieldValue));

                case "bit":
                    if (fieldValue == "1")
                    {
                        return(true);
                    }
                    else if (fieldValue == "0")
                    {
                        return(false);
                    }
                    return(Boolean.Parse(fieldValue));

                case "float":
                    return(Double.Parse(fieldValue));

                case "real":
                    return(Single.Parse(fieldValue));

                case "varbinary":
                    return(Byte.Parse(fieldValue));

                default:
                    return(fieldValue);
                }
            }