예제 #1
0
        /// <summary>
        /// Creates a command which will delete all entities
        /// </summary>
        public static CommandDefinition MakeDropTempTableCommand <TEntity>(
            string tableName,
            IDbTransaction transaction,
            IDialect dialect,
            int?commandTimeout,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var config = MicroCRUDConfig.Current;

            dialect = dialect ?? config.Dialect;
            var tableSchema = TableSchemaFactory.GetTableSchema(typeof(TEntity), dialect, config.SchemaFactory);

            if (tableSchema.Name != tableName)
            {
                throw new ArgumentException($"Attempting to drop table '{tableSchema.Name}', but said table name should be '{tableName}'");
            }

            var sql = dialect.MakeDropTempTableStatement(tableSchema);

            return(MakeCommandDefinition(sql, null, transaction, commandTimeout, cancellationToken));
        }