コード例 #1
0
        /// <summary>
        /// Adds the specified column to the targeted table only if the column doesn't exist.
        ///
        /// <para>Note: The method automatically resolve the type of the column.</para>
        /// </summary>
        ///
        /// <typeparam name="Table">The Table where we should search for the column type.</typeparam>
        /// <param name="self">The instance of the Cassandra Fluent Migrator helper.</param>
        /// <param name="table">The table to which we want to add the new column.</param>
        /// <param name="column">The new column.</param>
        /// <param name="shouldBeFrozen">Define if the type should be treated as a frozen type or not.</param>
        /// <returns>The Cassandra Fluent Migrator helper.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when one or all the specified arguments are invalid or null.</exception>
        /// <exception cref="ObjectNotFoundException">Thrown when the table doesn't exists.</exception>
        public static async Task <ICassandraFluentMigrator> AddColumnAsync <Table>([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string column, bool shouldBeFrozen = false)
            where Table : class
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator]");
            Check.NotEmptyNotNull(table, $"The argument [{nameof(table)}]");
            Check.NotEmptyNotNull(column, $"The argument [{nameof(column)}]");

            var typeName = self.GetColumnType <Table>(column, shouldBeFrozen);

            return(await self.ExecuteAddColumnAsync(table, column, typeName));
        }
コード例 #2
0
        /// <summary>
        /// Adds the specified column to the targeted table only if the column doesn't exist.
        /// </summary>
        ///
        /// <param name="self">The instance of the Cassandra Fluent Migrator helper.</param>
        /// <param name="table">The table to which we want to add the new column.</param>
        /// <param name="column">The new column.</param>
        /// <param name="type">The column type.</param>
        /// <param name="shouldBeFrozen">Define if the type should be treated as a frozen type or not.</param>
        /// <returns>The Cassandra Fluent Migrator helper.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when one or all the specified arguments are invalid or null.</exception>
        /// <exception cref="ObjectNotFoundException">Thrown when the table doesn't exists.</exception>
        public static async Task <ICassandraFluentMigrator> AddColumnAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string column, [NotNull] Type type, bool shouldBeFrozen = false)
        {
            // Validate the parameters.
            Check.NotNull(self, $"The argument [cassandra fluent migrator]");
            Check.NotNull(type, $"The argument [{nameof(type)}]");

            Check.NotEmptyNotNull(table, $"The argument [table]");
            Check.NotEmptyNotNull(column, $"The argument [{nameof(column)}]");

            return(await self.ExecuteAddColumnAsync(table, column, type.GetCqlType(shouldBeFrozen)));
        }