コード例 #1
0
        public static Type ToBasicNetType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType)
        {
            DbTypeMapEntry entry   = Find(sqlDbType);
            Type           NetType = entry.Type;

            return(NetType);
        }
コード例 #2
0
        /// <summary>
        /// Convert TSQL type to .Net data type
        /// </summary>
        /// <param name="sqlDbType"></param>
        /// <returns></returns>
        public static Type ToNetType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType)
        {
            DbTypeMapEntry entry   = Find(sqlDbType);
            Type           NetType = entry.Type;

            if (NetType == typeof(Decimal))
            {
                NetType = typeof(Nullable <Decimal>);
            }

            if (NetType == typeof(Boolean))
            {
                NetType = typeof(bool?);
            }

            if (NetType == typeof(Int32))
            {
                NetType = typeof(int?);
            }

            if (NetType == typeof(Int64))
            {
                NetType = typeof(long?);
            }

            if (NetType == typeof(DateTime))
            {
                NetType = typeof(DateTime?);
            }

            return(NetType);
        }
コード例 #3
0
 public DbTypeMapEntry(Type type,
                       DbType dbType,
                       Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType,
                       System.Xml.Schema.XmlTypeCode xSchemaType)
 {
     this.Type        = type;
     this.DbType      = dbType;
     this.SqlDbType   = sqlDbType;
     this.XSchemaType = xSchemaType;
 }
コード例 #4
0
        private static DbTypeMapEntry Find(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType)
        {
            object retObj = new DbTypeMapEntry(typeof(System.String), DbType.String, Microsoft.SqlServer.Management.Smo.SqlDataType.VarChar, XmlTypeCode.String);

            for (int i = 0; i < _DbTypeList.Count; i++)
            {
                DbTypeMapEntry entry = (DbTypeMapEntry)_DbTypeList[i];
                if (entry.SqlDbType == sqlDbType)
                {
                    retObj = entry;
                    break;
                }
            }

            return((DbTypeMapEntry)retObj);
        }
コード例 #5
0
 public DbTypeMapEntry(Type type,
     DbType dbType,
     Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType,
     System.Xml.Schema.XmlTypeCode xSchemaType)
 {
     this.Type = type;
     this.DbType = dbType;
     this.SqlDbType = sqlDbType;
     this.XSchemaType = xSchemaType;
 }
コード例 #6
0
        /// <summary>
        /// Convert TSQL data type to DbType
        /// </summary>
        /// <param name="sqlDbType"></param>
        /// <returns></returns>
        public static DbType ToDbType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType)
        {
            DbTypeMapEntry entry = Find(sqlDbType);

            return(entry.DbType);
        }
コード例 #7
0
        public static XmlTypeCode ToXmlType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType)
        {
            DbTypeMapEntry entry = Find(sqlDbType);

            return(entry.XSchemaType);
        }