コード例 #1
0
        /// <summary>
        /// Alter the specified User-Defined type by adding a new column only if it doesn't exist.
        /// If the UDT doesn't exists, the method throws an exception.
        /// If the column exists, the method skips the action.
        /// </summary>
        ///
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="udt">The name of the User-Defined type.</param>
        /// <param name="column">The name of the column to be added.</param>
        /// <param name="type">The type of 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 User-Defined type doesn't exists.</exception>
        public static async Task <ICassandraFluentMigrator> AlterUdtAddColumnAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string udt, string column, Type type, bool shouldBeFrozen = false)
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator]");
            Check.NotNull(type, $"The argument [{nameof(type)}]");

            Check.NotEmptyNotNull(udt, $"The argument [User-Defined type (udt)]");
            Check.NotNull(column, $"The argument [{nameof(column)}]");

            if (self.DoesUdtColumnExists(udt, column))
            {
                return(self);
            }

            return(await self.ExecuteAlterUdtAddColumnQuery(udt, column, type.GetCqlType(shouldBeFrozen)));
        }
コード例 #2
0
        /// <summary>
        /// Alter the specified User-Defined type by adding a new column only if it doesn't exist.
        /// If the UDT doesn't exists, the method throws an exception.
        /// If the column exists, the method skips the action.
        /// </summary>
        ///
        /// <typeparam name="TEntity">The calss where the method should search for the properties and their types.</typeparam>
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="udt">The name of the User-Defined type.</param>
        /// <param name="column">The name of the column to be added.</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 User-Defined type doesn't exists.</exception>
        public static async Task <ICassandraFluentMigrator> AlterUdtAddColumnAsync <TEntity>([NotNull] this ICassandraFluentMigrator self, [NotNull] string udt, string column)
            where TEntity : class
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator]");

            Check.NotEmptyNotNull(udt, $"The argument [User-Defined type (udt)]");
            Check.NotNull(column, $"The argument [{nameof(column)}]");

            if (self.DoesUdtColumnExists(udt, column))
            {
                return(self);
            }

            var typeName = self.GetColumnType <TEntity>(column);

            return(await self.ExecuteAlterUdtAddColumnQuery(udt, column, typeName));
        }