Ejemplo n.º 1
0
 private static Microsoft.SqlServer.Management.Smo.DataType Convert(DataType type)
 {
     switch (type.DbType)
     {
         case DbType.AnsiString:
             if (type.Size > 0)
             {
                 return Microsoft.SqlServer.Management.Smo.DataType.VarChar(type.Size);
             }
             else
             {
                 return Microsoft.SqlServer.Management.Smo.DataType.VarCharMax;
             }
         //case DbType.Binary:
         //    break;
         //case DbType.Byte:
         //    break;
         //case DbType.Boolean:
         //    break;
         //case DbType.Currency:
         //    break;
         //case DbType.Date:
         //    break;
         case DbType.DateTime:
             return Microsoft.SqlServer.Management.Smo.DataType.DateTime;
         case DbType.Decimal:
             return Microsoft.SqlServer.Management.Smo.DataType.Decimal(type.Scale, type.Size);
         //case DbType.Double:
         //    break;
         //case DbType.Guid:
         //    break;
         //case DbType.Int16:
         //    break;
         case DbType.Int32:
             return Microsoft.SqlServer.Management.Smo.DataType.Int;
         case DbType.Int64:
             return Microsoft.SqlServer.Management.Smo.DataType.BigInt;
         //case DbType.Object:
         //    break;
         //case DbType.SByte:
         //    break;
         //case DbType.Single:
         //    break;
         case DbType.String:
             if (type.Size > 0)
             {
                 return Microsoft.SqlServer.Management.Smo.DataType.NVarChar(type.Size);
             }
             else
             {
                 return Microsoft.SqlServer.Management.Smo.DataType.NVarCharMax;
             }
         //case DbType.Time:
         //    break;
         //case DbType.UInt16:
         //    break;
         //case DbType.UInt32:
         //    break;
         //case DbType.UInt64:
         //    break;
         //case DbType.VarNumeric:
         //    break;
         case DbType.AnsiStringFixedLength:
             return Microsoft.SqlServer.Management.Smo.DataType.Char(type.Size);
         case DbType.StringFixedLength:
             return Microsoft.SqlServer.Management.Smo.DataType.NChar(type.Size);
             //case DbType.Xml:
             //    break;
             //case DbType.DateTime2:
             //    break;
             //case DbType.DateTimeOffset:
             //    break;
         default:
             throw new ArgumentOutOfRangeException("type");
     }
 }
Ejemplo n.º 2
0
        private static Microsoft.SqlServer.Management.Smo.DataType Convert(DataType type)
        {
            switch (type.DbType)
            {
            case DbType.AnsiString:
                if (type.Size > 0)
                {
                    return(Microsoft.SqlServer.Management.Smo.DataType.VarChar(type.Size));
                }
                else
                {
                    return(Microsoft.SqlServer.Management.Smo.DataType.VarCharMax);
                }

            //case DbType.Binary:
            //    break;
            //case DbType.Byte:
            //    break;
            //case DbType.Boolean:
            //    break;
            //case DbType.Currency:
            //    break;
            //case DbType.Date:
            //    break;
            case DbType.DateTime:
                return(Microsoft.SqlServer.Management.Smo.DataType.DateTime);

            case DbType.Decimal:
                return(Microsoft.SqlServer.Management.Smo.DataType.Decimal(type.Scale, type.Size));

            //case DbType.Double:
            //    break;
            //case DbType.Guid:
            //    break;
            //case DbType.Int16:
            //    break;
            case DbType.Int32:
                return(Microsoft.SqlServer.Management.Smo.DataType.Int);

            case DbType.Int64:
                return(Microsoft.SqlServer.Management.Smo.DataType.BigInt);

            //case DbType.Object:
            //    break;
            //case DbType.SByte:
            //    break;
            //case DbType.Single:
            //    break;
            case DbType.String:
                if (type.Size > 0)
                {
                    return(Microsoft.SqlServer.Management.Smo.DataType.NVarChar(type.Size));
                }
                else
                {
                    return(Microsoft.SqlServer.Management.Smo.DataType.NVarCharMax);
                }

            //case DbType.Time:
            //    break;
            //case DbType.UInt16:
            //    break;
            //case DbType.UInt32:
            //    break;
            //case DbType.UInt64:
            //    break;
            //case DbType.VarNumeric:
            //    break;
            case DbType.AnsiStringFixedLength:
                return(Microsoft.SqlServer.Management.Smo.DataType.Char(type.Size));

            case DbType.StringFixedLength:
                return(Microsoft.SqlServer.Management.Smo.DataType.NChar(type.Size));

            //case DbType.Xml:
            //    break;
            //case DbType.DateTime2:
            //    break;
            //case DbType.DateTimeOffset:
            //    break;
            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }