Exemplo n.º 1
0
 /// <summary>
 /// Setups the columns.
 /// </summary>
 /// <param name="table">The table.</param>
 /// <param name="item">The item.</param>
 private static void SetupColumns(ITable table, dynamic item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (table == null)
     {
         throw new ArgumentNullException(nameof(table));
     }
     if (table.ContainsColumn(item.Column))
     {
         table.AddForeignKey(item.Column, item.FOREIGN_KEY_TABLE, item.FOREIGN_KEY_COLUMN);
     }
     else
     {
         table.AddColumn <string>(item.Column,
                                  Utilities.DataTypes.TypeConversionExtensions.To(Utilities.DataTypes.TypeConversionExtensions.To <string, SqlDbType>(item.COLUMN_TYPE), DbType.Int32),
                                  (item.COLUMN_TYPE == "nvarchar") ? item.MAX_LENGTH / 2 : item.MAX_LENGTH,
                                  item.IS_NULLABLE,
                                  item.IS_IDENTITY,
                                  item.IS_INDEX != 0,
                                  !string.IsNullOrEmpty(item.PRIMARY_KEY),
                                  !string.IsNullOrEmpty(item.UNIQUE),
                                  item.FOREIGN_KEY_TABLE,
                                  item.FOREIGN_KEY_COLUMN,
                                  item.DEFAULT_VALUE);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Setups the columns.
 /// </summary>
 /// <param name="table">The table.</param>
 /// <param name="item">The item.</param>
 private static void SetupColumns(ITable table, dynamic item)
 {
     if (item is null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (table is null)
     {
         throw new ArgumentNullException(nameof(table));
     }
     if (table.ContainsColumn(item.Column))
     {
         table.AddForeignKey(item.Column, item.FOREIGN_KEY_TABLE, item.FOREIGN_KEY_COLUMN);
     }
     else
     {
         string ColumnType = item.COLUMN_TYPE;
         table.AddColumn <string>(item.Column,
                                  ColumnType.To <SqlDbType>().To <DbType>(),
                                  (item.COLUMN_TYPE == "nvarchar") ? item.MAX_LENGTH / 2 : item.MAX_LENGTH,
                                  item.IS_NULLABLE,
                                  item.IS_IDENTITY,
                                  !(item.IS_INDEX is null),
                                  !string.IsNullOrEmpty(item.PRIMARY_KEY),
                                  !string.IsNullOrEmpty(item.UNIQUE),
                                  item.FOREIGN_KEY_TABLE,
                                  item.FOREIGN_KEY_COLUMN,
                                  item.DEFAULT_VALUE,
                                  item.ComputedColumnSpecification);
     }
 }
 /// <summary>
 /// Setups the columns.
 /// </summary>
 /// <param name="table">The table.</param>
 /// <param name="item">The item.</param>
 private static void SetupColumns(ITable table, dynamic item)
 {
     if (item == null)
         throw new ArgumentNullException(nameof(item));
     if (table == null)
         throw new ArgumentNullException(nameof(table));
     if (table.ContainsColumn(item.Column))
     {
         table.AddForeignKey(item.Column, item.FOREIGN_KEY_TABLE, item.FOREIGN_KEY_COLUMN);
     }
     else
     {
         table.AddColumn<string>(item.Column,
             Utilities.DataTypes.TypeConversionExtensions.To(Utilities.DataTypes.TypeConversionExtensions.To<string, SqlDbType>(item.COLUMN_TYPE), DbType.Int32),
             (item.COLUMN_TYPE == "nvarchar") ? item.MAX_LENGTH / 2 : item.MAX_LENGTH,
             item.IS_NULLABLE,
             item.IS_IDENTITY,
             item.IS_INDEX != 0,
             !string.IsNullOrEmpty(item.PRIMARY_KEY),
             !string.IsNullOrEmpty(item.UNIQUE),
             item.FOREIGN_KEY_TABLE,
             item.FOREIGN_KEY_COLUMN,
             item.DEFAULT_VALUE);
     }
 }