Ejemplo n.º 1
0
        /// <summary>
        /// Generate SQL code to alter table
        /// </summary>
        /// <param name="table">Table object</param>
        /// <param name="columnAction">Alteration kind</param>
        /// <param name="field">Field object</param>
        /// <returns>SQL code</returns>
        public override string AlterTableColumnSQL(InTable table, ColumnAction columnAction, InField field)
        {

            string code = "ALTER TABLE " + AsFieldName(table.Name);
            switch (columnAction)
            {
                case ColumnAction.Remove:
                    code += " DROP COLUMN " + AsFieldName(field.Name);
                    break;

                case ColumnAction.Recreate:
                    code += " DROP COLUMN " + AsFieldName(field.Name);
                    code += ", ";
                    code += " ADD COLUMN " + AsFieldName(field.Name) + " " + GetSqlType(field);
                    break;

                case ColumnAction.Insert:
                    code += " ADD COLUMN " + AsFieldName(field.Name) + " " + GetSqlType(field);
                    break;

                case ColumnAction.ChangeType:
                    code += " ALTER COLUMN " + AsFieldName(field.Name) + " TYPE " + GetSqlType(field);
                    break;

                default: code = null;
                    break;
            }
            return code;
        }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (InField != null ? InField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Index != null ? Index.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Characters != null ? Characters.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Direction != null ? Direction.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ MatchCase.GetHashCode();
         hashCode = (hashCode * 397) ^ (StartIndex != null ? StartIndex.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 3
0
  public override string GetSqlType(InField f)
  {
      if ((f.FieldType == typeof(string)) && (f.Indexed))
      {
          f.Size = 512;
      }
 
      if (
          ((f.FieldType == typeof(string)) && (f.Size >0)  && (f.Size < int.MaxValue))
          ||
          (f.DBType == DbType.StringFixedLength)
          )
      {
          return string.Format("nvarchar({0})", f.Size);
      }
      return base.GetSqlType(f);
  }
Ejemplo n.º 4
0
 public override DbParameter SetupParameter(DbParameter param, InField f)
 {
     OleDbParameter odbp=(OleDbParameter)param;
     odbp.Size = f.Size;
     if (odbp.Size == 0)
     {
         switch (GetDbType(f.FieldType))
         {
             case DbType.String:
                 odbp.Size = 1024;
                 break;
             default:
                 odbp.Size =  Marshal.SizeOf(f.FieldType);
                 break;
         }
     }
     odbp.Scale = f.Scale;
     odbp.Precision = f.Precision;
     return odbp;
 }
Ejemplo n.º 5
0
        public override DbParameter SetupParameter(DbParameter param, InField f)
        {
            SqlParameter p = (SqlParameter)param;
            p.Size = f.Size;
            if (p.Size == 0)
            {

                p.Size = Int32.MaxValue; 
                switch (GetDbType(f.FieldType))
                {
                    case DbType.Decimal:
                        if (f.Scale==0) 
                            f.Scale=15;
                        if (f.Precision == 0)
                            f.Precision = 38;
                        //p.Size = Marshal.SizeOf(f.FieldType);
                        break;
                        
                        /*
                    case DbType.DateTime:
                    case DbType.DateTimeOffset:
                    case DbType.Int16:
                    case DbType.Int32:
                    case DbType.Int64:
                    case DbType.Binary:
                        p.Size = Int32.MaxValue;
                        break;



                    case DbType.String:
                        p.Size = Int32.MaxValue;
                        break;
                         */
                    default:
                        // p.Size = Marshal.SizeOf(f.FieldType);
                        break;
                }
            }
            p.Scale = f.Scale;
            p.Precision = f.Precision;
            
            return p;
        }
Ejemplo n.º 6
0
 public override string AsFieldName(InField fld, ProviderSpecifics.StatementKind sk)
 {
     if ((fld.FieldType == typeof(string)) && ((sk == StatementKind.OrderBy) || (sk == StatementKind.Where)))
         return string.Format("CAST({0} as NVARCHAR(max))",base.AsFieldName(fld, sk));
     return base.AsFieldName(fld, sk);
 }