Пример #1
0
        /// <summary>
        ///     Builds commands for the given <see cref="RenameIndexOperation" />
        ///     by making calls on the given <see cref="MigrationCommandListBuilder" />.
        /// </summary>
        /// <param name="operation"> The operation. </param>
        /// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
        /// <param name="builder"> The command builder to use to build the commands. </param>
        protected override void Generate(RenameIndexOperation operation, IModel model, MigrationCommandListBuilder builder)
        {
            var index = FindEntityTypes(model, operation.Schema, operation.Table)
                        ?.SelectMany(t => t.GetDeclaredIndexes()).Where(i => i.GetName() == operation.NewName)
                        .FirstOrDefault();

            if (index == null)
            {
                throw new NotSupportedException(
                          TaosStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName()));
            }

            var dropOperation = new DropIndexOperation
            {
                Schema = operation.Schema,
                Table  = operation.Table,
                Name   = operation.Name
            };

            dropOperation.AddAnnotations(_migrationsAnnotations.ForRemove(index));

            var createOperation = new CreateIndexOperation
            {
                IsUnique = index.IsUnique,
                Name     = operation.NewName,
                Schema   = operation.Schema,
                Table    = operation.Table,
                Columns  = index.Properties.Select(p => p.GetColumnName()).ToArray(),
                Filter   = index.GetFilter()
            };

            createOperation.AddAnnotations(_migrationsAnnotations.For(index));

            Generate(dropOperation, model, builder, terminate: false);
            builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator);

            Generate(createOperation, model, builder);
        }
        protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression source, LambdaExpression keySelector, bool ascending)
        {
            var translation = base.TranslateThenBy(source, keySelector, ascending);

            if (translation == null)
            {
                return(null);
            }

            var orderingExpression     = ((SelectExpression)translation.QueryExpression).Orderings.Last();
            var orderingExpressionType = GetProviderType(orderingExpression.Expression);

            if (orderingExpressionType == typeof(DateTimeOffset) ||
                orderingExpressionType == typeof(decimal) ||
                orderingExpressionType == typeof(TimeSpan) ||
                orderingExpressionType == typeof(ulong))
            {
                throw new NotSupportedException(
                          TaosStrings.OrderByNotSupported(orderingExpressionType.ShortDisplayName()));
            }

            return(translation);
        }
Пример #3
0
 /// <summary>
 ///     Throws <see cref="NotSupportedException" /> since this operation requires table rebuilds, which
 ///     are not yet supported.
 /// </summary>
 /// <param name="operation"> The operation. </param>
 /// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
 /// <param name="builder"> The command builder to use to build the commands. </param>
 protected override void Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder)
 => throw new NotSupportedException(
           TaosStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName()));
Пример #4
0
 /// <summary>
 ///     Throws <see cref="NotSupportedException" /> since this operation requires table rebuilds, which
 ///     are not yet supported.
 /// </summary>
 /// <param name="operation"> The operation. </param>
 /// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
 /// <param name="builder"> The command builder to use to build the commands. </param>
 /// <param name="terminate"> Indicates whether or not to terminate the command after generating SQL for the operation. </param>
 protected override void Generate(
     DropPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)
 => throw new NotSupportedException(
           TaosStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName()));